PDA

View Full Version : [CLOSED] grid.columns is returning empty array if columns are added to grid using reconfigure



agarapati
29 Jul 2015, 10:19 PM
STAND-ALONE TESTCASE
https://fiddle.sencha.com/#fiddle/mq2

ADDITIONAL INFO

Code:

Ext version tested:

Ext 4.2.2 rev 1144
Browser versions tested against:

____
IE11
FF39 (firebug 2.0.x installed)
Chrome 44
Description:

Grid columns property is not getting updated if columns are added from controller using reconfigure.
As shown in the Fiddle example, our columns will be generated from a ajax call, we are using grid.reconfigure to set store and columns for a grid.
We should able to hide/delete the column so we added a delete button in column header.
Using handler we tried to get instance of button we tried to use grid.columns[button.colIndex].hide().
We observed grid.columns is not getting updated it is giving empty array.
Steps to reproduce the problem:

Open above fiddle url
In app/Controlelrs/Grids.js we can see onLaunch method we are defining grid columns and store.
We used handler to call hideColumn method in button definition where we tried to use grid.columns
Even after grid is reconfigured and columns and data is displayed in browser, grid columns array is not getting updated.
The result that was expected:

grid.columns property should be updated once columns of the grid are added or removed using reconfigure method
The result that occurs instead:

grid.columns property is not getting updated if columns are added to grid from controller using reconfigure

tristan.lee
3 Aug 2015, 8:08 PM
columns is a config property that's unrelated to the columns generated when using reconfigure(). In 4, you can make reference to the private class ColumnManager to get the columns:


hideColumn: function(button, Event) {
var grid = Ext.getCmp('investmentsGrid'),
cm = grid.getColumnManager(),
cols = cm.getColumns();

if (cols.length > 0) {
cols[button.colIndex].hide();
}
}

agarapati
4 Aug 2015, 9:01 PM
Thanks lee for clarification and helping me out.