I face a similar problem with the grid's 'applyState' function.
I basically initialize a tree panel with a store and only 1 column to start with. Depending on the necessary AJAX calls I need to do, I get a list of a few fields (columns) that I use to reconfigure the grid with at first and apply the state to these afterwards (to resize, reorder, hide them depending on user's settings in another page).
Code:
reconfigureGrid: function(columns) {
var stateProvider = Ext.state.Manager.getProvider();
var grid = this.getView();
// reconfigure with generated columns at first
grid.reconfigure(null, columns);
...
Afterwards, I get the state object and map its stateIds to the ones from the grid columns.
Code:
...
// clear the grid's state
stateProvider.clear(grid.stateId);
var state = stateProvider.get(grid.stateId);
if (state) {
this.mapStateIds();
...
and in the same if-clause I apply the state object to the grid:
Code:
...
grid.applyState(state);
}
The state gets applied to the grid's columns, but there seems to be some problem with the hidden columns from the state.columns config:
Columns that were shown in the grid and should now be hidden by the state object, are technically hidden ('hidden' property is true and grid's visibleColumnManager doesn't contain them), but are still rendered and visible. They are all stacked up and overlap on the very first grid column.
Without any columns hidden:
colBug1.png
The column 'Po Box' should get hidden by the state object (which a user can do on another page), but gets placed in the first row, overlapping the 'rownumberer' column and the 'ID' column.
colBug2.png
I was debugging in the internal functions and I think it gets caused somewhere when applying the state columns to the headerCt, which then adds the columns to itself:
(Ext.panel.Table - applyState):
Code:
if (columns) {
me.headerCt.applyColumnsState(columns);
}
(Ext.grid.header.Container - applyColumnsState):
Code:
if (moved) {
me.removeAll(false);
me.add(newOrder);
me.purgeCache();
}
There in the add() function the items get added to the headerCt, but it's only visible (that the columns that should be hidden are overlapping others) after the layout is updated:
(Ext.container.Container - add):
Code:
// We need to update our layout after adding all passed items
// Unless we only added floating items.
if (needsLayout) {
me.updateLayout();
}
Note: if the columns, that should be hidden by applying the state, are manually (via column menu or in the code) shown first and then hidden again, they behave the same as usual/expected.