PDA

View Full Version : [OPEN] [FIXED-1366]Problem with Grid sorting with state enabled



nicholasnet
28 Oct 2010, 12:52 PM
Ext Version:
3.3

Browser affected
Firefox 3.6, Chrome 5.0, IE 8.0

Ways to reproduce bug
Go to: http://dev.sencha.com/deploy/dev/examples/grid/array-grid.html
Sort company field -> Refresh the browser -> Now try to sort any field
IT DOES NOT WORK....

Solution
None found so far

Algorhythm
3 Nov 2010, 3:26 PM
I am having the same issue.

evant
3 Nov 2010, 7:29 PM
This has been fixed in SVN, thanks for the report.

jrusin
9 Nov 2010, 2:52 PM
also check
that if col is not automated generated id but user id it should be:


setState : function(col, state) {
Ext.apply(this.config[this.getIndexById(col)], state);
}

return1.at
18 Feb 2011, 7:21 AM
the bug ist still in version 3.3.1 when used with "editable" instead of of "sortable"

here is my working override for 3.3.1 (i already reported this via ticket system before the release)



Ext.override(Ext.grid.GridPanel, {
applyState: function (state) {
var cm = this.colModel,
cs = state.columns,
store = this.store,
s, c, colIndex;

if (cs) {
for (var i = 0, len = cs.length; i < len; i++) {
s = cs[i];
c = cm.getColumnById(s.id);
if (c) {
colIndex = cm.getIndexById(s.id);
cm.setState(colIndex, {
hidden: s.hidden,
width: s.width,
sortable: s.sortable,
editable: s.editable
});
if (colIndex != i) {
cm.moveColumn(colIndex, i);
}
}
}
}
if (store) {
s = state.sort;
if (s) {
store[store.remoteSort ? 'setDefaultSort' : 'sort'](s.field, s.direction);
}
s = state.group;
if (store.groupBy) {
if (s) {
store.groupBy(s);
} else {
store.clearGrouping();
}
}

}
var o = Ext.apply({}, state);
delete o.columns;
delete o.sort;
Ext.grid.GridPanel.superclass.applyState.call(this, o);
},

getState: function () {
var o = {
columns: []
},
store = this.store,
ss, gs;

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;
}
if (c.sortable) {
o.columns[i].sortable = true;
}
if (c.editable) {
o.columns[i].editable = true;
}
}
if (store) {
ss = store.getSortState();
if (ss) {
o.sort = ss;
}
if (store.getGroupState) {
gs = store.getGroupState();
if (gs) {
o.group = gs;
}
}
}
return o;
}
});