Looking at applyState() in Grid, I see that saving column width, column hidden-ness, and sort info has already been set up.
So, I can do something like this for column resizing:
Code:
comp.addListener(Events.ColumnResize , new Listener<GridEvent>() {
public void handleEvent(GridEvent ge) {
Grid g = ge.getGrid();
g.getState().put("width" + ge.getColIndex() , ge.getWidth());
g.saveState();
}
});
And I can do something like this for sort info:
Code:
comp.addListener(Events.SortChange , new Listener<GridEvent>() {
public void handleEvent(GridEvent ge) {
Grid g = ge.getGrid();
g.getState().put("sortField", ge.getSortInfo().getSortField());
g.getState().put("sortDir", ge.getSortInfo().getSortDir());
g.saveState();
}
});
However, when looking at GridEvent, I don't see anything about hidden-ness of columns. There is a HiddenChange event in ColumnModel, though. If I listen for events on the ColumnModel, I can't tell from the ColumnModelEvent what Grid it's attached to. Any suggested way of doing this?
Also, what about column ordering? If someone re-orders columns, there is nothing in Grid's applyState() for that. Again, this appears to be in ColumnModelEvent, but not GridEvent.