PDA

View Full Version : [FIXED-714] Stateful grid and reordered columns issue in 3.2.2 only



sareko
11 Jun 2010, 12:06 PM
Ext version tested:

Ext 3.2.2 ONLY (3.2.1 does not have the bug)


Adapter used:

ext


css used:

only default ext-all.css




Browser versions tested against:

Firefox
IE8
Chrome


Operating System:

Windows 7


Description:

Stateful grid does not restore columns correctly if the columns are reordered since 3.2.2. Note that this is a new bug in 3.2.2 and the bug is not present in 3.2.1



See this URL : http://www.extjs.com/deploy/dev/examples/grid/array-grid.html


Steps to reproduce the problem:

Use the test case "Basic Array Grid" (the simple stateful grid) from the examples that come with the ExtJS download
Move the Company column to be the last in the grid
Hide all of the columns EXCEPT Company
Refresh the page
Notice that you now have all the columns visible except company when using 3.2.2. If you are using 3.2.1, then, as expected, Company is the only column visible. (So it works on the URL above, the sample you guys have online since it uses 3.2.1)


The result that was expected:

The same behavior as 3.2.1, Company is the only column that should be visible after reloading the page


The result that occurs instead:

All columns except Company are visible



That one took me a bit :) I thought i was going crazy, since it worked fine on extjs.com but failed for me on my test server, until I realized the online samples are still on 3.2.1, then tried that locally and it worked.

sareko
11 Jun 2010, 12:29 PM
Looking through the code, the culprit seems to be a change made to use the new columnmodel's setState method. The method relies on the position of the column, while the previous way of doing it set the column properties directly. Since it is called -before- the columns are reordered from state, it applies state to the wrong columns.

Simply change (in applyState of the grid panel):



if(c){
oldIndex = cm.getIndexById(s.id);
cm.setState(i, {
hidden: s.hidden,
width: s.width
});
if(oldIndex != i){
cm.moveColumn(oldIndex, i);
}
}

with:


if(c){
oldIndex = cm.getIndexById(s.id);
if(oldIndex != i){
cm.moveColumn(oldIndex, i);
}
cm.setState(i, {
hidden: s.hidden,
width: s.width
});
}

and it works, at least in my tests :)

sareko
11 Jun 2010, 12:47 PM
Ahh, nevermind, I got ahead of myself. The fix above only works in the simplest scenarios. So i simply did an override that applies the old applyState of the grid panel from 3.2.1 to 3.2.2, and that works good.

I'm sure there's a good reason for the new code, but for now the 3.2.1 version simply works better.

evant
15 Jun 2010, 12:31 AM
This has been corrected in SVN, thanks for the report.