View Full Version : Getting empty array for no reason

30 Mar 2012, 8:20 AM
Why do I get an empty array on the red line? I want the out put of the red line to be the same as the blue line. Thanks for your help.

copyFromGrid = Ext.ComponentQuery.query("#" + copyFromGrid)[0];

console.log(copyFromGrid.columns); => array of Column objects

grid.reconfigure(copyFromGrid.getStore(), copyFromGrid.columns);

console.log(copyFromGrid.columns); => Empty array

30 Mar 2012, 9:53 AM
Why are you executing reconfigure with the same store and columns?

30 Mar 2012, 10:01 AM
I have three grids: User, Role, and Workspace. Workspace is to model the one to many relationship between users and roles (one user can have many roles). When double clicking user's row, I want Workspace to have the same store and column as that of the role grid. That way I can then drag and drop roles between the Role grid and Workspace grid. This is an interactive way of editing roles for a user. Role grid here is the "copyFromGrid" in the code. grid in "grid.reconfigure" is the Workspace grid.

Because copyFromGrid.columns got cleared out (empty array), Role grid's headers disappear after I double click a row in User grid.

Hope that clarifies.

30 Mar 2012, 11:26 AM
This did the trick. Any better way to do this?

copyFromGrid = Ext.ComponentQuery.query("#" + copyFromGrid)[0];
Ext.each(copyFromGrid.columns, function(column, index) {
grid.reconfigure(copyFromGrid.getStore(), columns);