View Full Version : Store grid state

28 Feb 2007, 3:55 PM

the new column menu and the possibilities to reorder the columns and lock / unlock let me see the need of a "restoreState" like its done on the BorderLayout maybe. Is there anything in planning?

20 Jun 2007, 12:31 AM
I am also interested in a solution for this. Will the next Ext version include this option?

If not,
There is a solution suggested in: http://extjs.com/forum/showthread.php?t=5219&highlight=grid+state.
Did anyone try it? Does it work OK?


23 Jun 2007, 10:33 PM
The solution by JCA works... you gota set the manager...

Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

and store the state...

storeGridState: function(){
var sortState = ds.getSortState();
if (sortState) {
var colIdx = cm.findColumnIndex(sortState['field']);
cm.config[colIdx]['direction'] = sortState['direction'];
var State = Ext.encode(cm.config);
Ext.state.Manager.set("gridState", State);

grid.getColumnModel().on("hiddenchange", grid.storeGridState, grid);



restore code is on the other thread link...

now just need to figure out a pretty way on how to store the height of the grid box... if it is resizeable...

i got...

Ext.state.Manager.set("gridSizeState", Ext.get('formData-grid').getSize().height);

and then on the grid config...

ds: ds,
cm: cm,
height: Ext.state.Manager.get("gridSizeState", 300);

wondering if there is a better way to get the grid height... and may be add a listener for it.