PDA

View Full Version : [DUPE-1366]GridPanel's columns lost sortable:true after CookieProvider is used



dmvasiliev
7 Nov 2010, 8:43 AM
I have GridPanel with several columns.
For each column I use


sortable: true

Also I use CookieProvider:


Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

Bug:
When I sort some column - the cookie is creating.
After page refresh - all columns configs became "sortable: false" and column's can't sort.

I saw this strange thing only in version 3.3.

jrusin
7 Nov 2010, 12:28 PM
I have the same for HttpProvider
after some investigations:

GridView.js (3.2.1)

applyState : function(state){
...
if(cs){
for(var i = 0, len = cs.length; i < len; i++){
s = cs[i];
c = cm.getColumnById(s.id);
if(c){
c.hidden = s.hidden;
c.width = s.width;

GridView.js (3.3.0)

applyState : function(state){
...
if(cs){
for(var i = 0, len = cs.length; i < len; i++){
s = cs[i];
c = cm.getColumnById(s.id);
if(c){
cm.setState(s.id, {
hidden: s.hidden,
width: s.width
});
and new ColumnMode.setState

ColumnModel.js

/**
* @private
* Setup any saved state for the column, ensures that defaults are applied.
*/
setState : function(col, state) {
state = Ext.applyIf(state, this.defaults);
Ext.apply(this.config[col], state);
}

in the ColumnModel.js you can found


defaultSortable: false,
...
setConfig ....
...
this.defaults = Ext.apply({
width: this.defaultWidth,
sortable: this.defaultSortable
}, this.defaults);


so default.sortable is false .. and you menu is grayed.

so if Your defaults are not configured to sortable:true this won't work.
This is bug for me --> sortable should be for column not for model :-(

add to your grid.cm

setState : function(col, state) {
Ext.apply(this.config[col], state);
}
and for me works as in 3.2.1

dmvasiliev
7 Nov 2010, 1:00 PM
jrusin,
Thank you very much for help and full explanation!
Your decision works for me too! (v. 3.3).


And to Ext Team: could you pay attention for this problem...

evant
7 Nov 2010, 7:48 PM
Dupe of: http://www.sencha.com/forum/showthread.php?114048-FIXED-1366-Problem-with-Grid-sorting-with-state-enabled

jrusin
9 Nov 2010, 2:53 PM
that if col is not automated generated id but column id is provided by user it should be:


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