PDA

View Full Version : [FIXED-391][3.0.3] Grid doesn't save grouping state



durlabh
30 Nov 2009, 11:57 AM
Refer to thread:
http://www.extjs.com/forum/showthread.php?t=26963.

This needs to be fixed in trunk too:



Ext.override(Ext.grid.GridPanel, {
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.hidden = s.hidden;
c.width = s.width;
var oldIndex = cm.getIndexById(s.id);
if(oldIndex != i){
cm.moveColumn(oldIndex, i);
}
}
}
}
if(state.sort){
this.store[this.store.remoteSort ? 'setDefaultSort' : 'sort'](state.sort.field, state.sort.direction);
}
if(state.group && this.store.groupBy){
this.store.groupBy(state.group);
}
},
getState : function(){
var o = {columns: []};
for(var i = 0, c; c = this.colModel.config[i]; i++){
o.columns[i] = {
id: c.id,
width: c.width
};
if(c.hidden){
o.columns[i].hidden = true;
}
}
var ss = this.store.getSortState();
if(ss){
o.sort = ss;
}
if(this.store.getGroupState){
var gs = this.store.getGroupState();
if(gs){
o.group = gs;
}
}
return o;
}
});

Condor
30 Nov 2009, 11:53 PM
This is a feature request and not a bug.

Also, I don't like the solution, because it puts grouping related code in GridPanel.

Instead, GridPanel should forward the getState and applyState methods to the view, so GroupingView can get/apply the grouping.

durlabh
2 Dec 2009, 12:33 PM
I agree with Condor. At this point, getState and applyState get the state info from the store. Same ways, columnModel state is being retrieved/ applied from within GridPanel. However, these should be responsibility of the gridView and columnModel. This way, view and columnModel will not be that tightly coupled with the gridPanel itself.

evant
2 Dec 2009, 3:19 PM
Well, technically yes, but the ColumnModel and the GridView ~are~ tightly coupled with the grid, the only reason to include the extra complexity is for possible subclasses to push extra properties onto the state object.

durlabh
2 Dec 2009, 4:10 PM
In that case, I consider this a bug as it is fixed in 2.x branch. Can you please fix in 3.x branch too.

evant
15 Dec 2009, 9:47 PM
Fix applied to svn in rev #5790 for patch release 3.2.