View Full Version : Grid State Restore using Cookies

18 Nov 2013, 6:26 AM
I am having multiple applications in my project.
I need to save and restore the grid state for all the applications.

Creating and displaying application:
I am creating each window in the following way
var frmOrderdetails = Ext.create('iMakeClient.view.SimpleOrder',{modal: false});

I am setting the following properties to a grid panel
stateful: true
stateId: OrderGridState

Closing the application:
Taking the particular application's window object and calling close() method.

In the application controller's init action, i am having the following code

When i refresh my browser and open an application, it is restoring the last saved state.
If i close and re-open the same application, it is not restoring the last saved state. It is displaying the default initial state of the grid.

But i need to restore the last saved state while closing and opening the application also.

Can someone please tell me why it is not working on application re-open?
What needs to be changed to make it work?

Thanks in advance.

18 Nov 2013, 8:04 AM
Are you sure you are not clearing things out when you close the browser?

Does our basic grid example work?

It uses stateful grid.

18 Nov 2013, 11:11 PM
Thanks for the reply scottmartin.

I got the problem.
I had not set id for each column in the grid.
I had set itemId for each column. That works only on first time.

After i have set id for all the columns, it is restoring while application re-open also.

4 Apr 2014, 11:34 PM
I have the same problem, with a rather large grid, and i found that vinothsencha is right, if i set id (not itemId) for each column, it works perfectly. My problem is that i'm rendering several grids of the same kind in my app simultaneously, so i can't assign id for each column...

any ideas as to why this id fix thing is happening? workarounds?


17 Apr 2014, 6:12 AM
Landoni and vinothsencha, on the columns you should be setting stateId, not id.
As per the documentation: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.column.Column-cfg-stateId
The stateId of a column only needs to be unique within the grid.