-
26 Oct 2010 1:28 PM #1
[FIXED-1365] GridPanel::applyState may call ColumnModel::setState incorrectly (3.3)
[FIXED-1365] GridPanel::applyState may call ColumnModel::setState incorrectly (3.3)
Ext version tested:
- Ext 3.3.0 (Bug exists here. The setState function in Ext.grid.ColumnModel was introduced in Ext 3.3.0)
Browser versions tested against:- IE9
- FF3 (firebug 1.5.4 installed)
- Chrome 7
Operating System:- Windows 7 Enterprise
Description:- The setState function of Ext.grid.ColumnModel (which is new to 3.3) can only accept an integer (or a string containing an integer) as the first argument, since the this.config object is an array. See the second line:The problem is that Ext.grid.GridPanel::applyState calls this function and passes a string value as the first argument (in red below) if the id (string) property of a column was specified in the grid's column model:Code:
setState : function(col, state) { state = Ext.applyIf(state, this.defaults); Ext.apply(this.config[col], state); }Code:applyState : function(state){ var cm = this.colModel, cs = state.columns, store = this.store, s, c, oldIndex; 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 }); oldIndex = cm.getIndexById(s.id); if(oldIndex != i){ cm.moveColumn(oldIndex, i); } } } } // . . . }
Steps to reproduce (and test case):
Actually this problem can be reproduced on an Ext 3.3 sample page.- Go to this URL : http://dev.sencha.com/deploy/dev/exa...rray-grid.html
- Hide the Company column
- Reload. The company column didn't hide. This is because the column model provides an id (string) for the company column.
- Try on any other column - it will work elsewhere. This is because the other columns don't provide an id (string).
Possible fix:- Change the beginning of the GridPanel::applyState function to the following (changes in red):
Code: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); //moved to beginning of block cm.setState(colIndex, { hidden: s.hidden, width: s.width }); if(colIndex != i){ cm.moveColumn(colIndex, i); } } } } // . . . }
-
3 Nov 2010 7:30 PM #2
This has been fixed in SVN, thanks for the report.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
16 Feb 2011 1:09 PM #3
Evan,
Has this been fixed in 3.3.1 ?
Thanks!
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
[2.x][CLOSED] GridPanel applyState: Hidden doesn't hide column header
By durlabh in forum Ext 2.x: BugsReplies: 5Last Post: 7 Jun 2012, 12:46 AM -
[OPEN-1268] GridPanel.applyState does not handle column total width correctly
By hjones in forum Ext 3.x: BugsReplies: 0Last Post: 14 Sep 2010, 10:25 AM -
GridPanel with forceFit sizes columns incorrectly
By oboyklubben in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 17 Sep 2008, 10:53 PM -
GridPanel rendered incorrectly in a TabPanel
By puzzles in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 12 Oct 2007, 9:52 AM


Reply With Quote