[2.x][CLOSED] GridPanel applyState: Hidden doesn't hide column header
I'm not sure whether others have noticed this as well or not. In couple of my cases, I noticed that when a column is hidden in the stored state and state is restored on a rendered grid, grid headers remain visible while content is hidden. I propose the following fix:
Code:
Ext.grid.GridPanel.override({
applyState : function(state){
var cm = this.colModel;
var cs = state.columns;
if(cs){
for(var i = 0, len = cs.length; i < len; i++){
var s = cs[i];
var c = cm.getColumnById(s.id);
if(c){
c.width = s.width;
var oldIndex = cm.getIndexById(s.id);
cm.setHidden(oldIndex, s.hidden);
if(oldIndex != i){
cm.moveColumn(oldIndex, i);
}
}
}
}
if(state.sort){
this.store[this.store.remoteSort ? 'setDefaultSort' : 'sort'](state.sort.field, state.sort.direction);
}
}
});
Restore stateful Grid Columns on click of a button
i have given Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
and " stateful: true," to save the columns of grid in cookies and get those. I would like to have a button for the grid which will restore all the columns. Can you pls guide me how can i use the applyState in the restore buttton?
this still occurs in 4.0.7
Quote:
Originally Posted by
Condor
@brian:You assume that applyState is only called with the state from the state manager when the component is created.However, several people use getState and applyState to save and restore column layout (e.g. a "Restore columns" button).This means that applyState can also be called when the grid is already rendered.
To me it seems this still doesn't work. In 4.0.7 I also use getState and applyState in a grid panel. applyState hides some columns (content) but the header still remain...