View Full Version : Column State in a Grid

14 Oct 2011, 12:09 PM
This may be impossible but I don't think so...I think I'm too stupid.

Our requirements have us saving "user preferences" essentially they want our Ext components to be stateful. Easy right because it's built into Ext!!

So I have my Grid:

ns.Grid = Ext.extend(commonNs.BaseGridPanel,{
store: store,
stateful: true,
stateId: 'gridState',
stateEvents: ['columnmove', 'columnresize', 'sortchange', 'groupchange', 'hiddenchange'],
colModel: new Ext.grid.ColumnModel({
columns: [...]

Now we have some buttons that make certain columns in the column model hide and unhide and I'm using:

colModel.setHidden(index, bool);

By default all but 1 are visible and I hacked it so that if there isn't a state for this grid it hides the column I want to afterRender.

Unfortunately if I click the buttons (which also change the grouping) and reload the page the groupings are remembered but the columns that had been hidden and all of my columns are showing up.

My initial thought is because the event 'hiddenchange' isn't a grid event but I can't make colModel stateful so that it remembers things about itself. Any ideas?