2
votes

I'm on ExtJS 4 and using an MVC approach. I've created a simple grid view class, and have added a componentquery type 'ref' to that view in my controller. Within the initial grid view itself I set several columns to be hidden and some to be visible by default. The rendering of the grid with those settings is all working fine.

Then I have a button that, when clicked and based on some other conditions, will make some of the initially hidden grid columns visible. This works as well.

But what I need is a way to later 'reset' the grid to its initial view (with the correct columns hidden/visible, as they were initially).

I've tried various permutations of the following with no effect:

var theGrid = this.getTheGrid();
theGrid.reconfigure(store, theGrid.initialConfig.columns);
theGrid.getView().refresh();

I suppose I could loop through every column and reset its 'hidden' state, but would think there's a way to just 'reset' back to what's set in the class? Advice?

SOLUTION UPDATE

Appreciate the pointer from tuespetre. For anyone coming along in the future looking for specifics, here is what was needed (at least for my implementation):

  • Within the view, moved the column defs into a variable

  • Within the view, columns ref within the class becomes:

    columns: myColumns,
    
  • Within the view, the following function created within the class:

    resetGrid: function(){
        this.reconfigure(null, myColumns);
    },
    
  • Within the controller:

    var theGrid = this.getTheGrid();
    theGrid.resetGrid();
    
1

1 Answers

1
votes

You will just need to create a function on your view class to encapsulate that functionality.