You found a bug! We've classified it as
a bug in our system.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
-
Ext User
[FIXED] GRID restore state bug
When hidding a column from the grid, that was previously already saved in the grid's state as the "sortField", GXT fails to restore the grid when next the application is started.
I fixed this by overriding Grid. In the overridden class I overwrote applyState(), with the following code (note: I marked my additions):
@Override
protected void applyState(Map<String, Object> state) { super.applyState(state);
if(isStateful())
for(ColumnConfig c: cm.getColumns()) {
String id = c.getId();
if(state.containsKey("hidden" + id)) {
if(id.equals((String)state.get("sortField"))) //Added
state.remove("sortField"); //Added
c.setHidden((Boolean)state.get("hidden" + id));
}
if(state.containsKey("width" + id))
c.setWidth((Integer)state.get("width" + id));
String sortField = (String)state.get("sortField");
if(store.getLoader() == null && sortField != null) {
String sortDir = (String)state.get("sortDir");
SortDir dir = SortDir.findDir(sortDir);
store.sort(sortField, dir);
}
}
}
This works for me. There are probably other ways to prevent this bug from showing (for example by adding checks on the store's sort method. Either way, I hope that this is fixed in a next release.
-
Thanks for reporting this. It is fixed in SVN now
-
Ext User
Grid Restore State
Hi,
I have given "stateful: true," in the GridPanel. I can hide columns and save it in cookies. I would like to have a restore button, clicking on which should show me the default selected columns. How can i call applyState function to restore the hidden columns? Can anyone give me an example?
-
Ext User
i see you look more for a extjs solution than a gxt solution. so its the wrong category in thins forum.