PDA

View Full Version : Grid State Restore using Cookies



vinothsencha
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});
frmOrderdetails.show();


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
Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));


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.

scottmartin
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?
http://docs.sencha.com/extjs/4.2.1/extjs-build/examples/build/KitchenSink/ext-theme-neptune/#array-grid

It uses stateful grid.

vinothsencha
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.

landoni
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?

thanks

CaCtus491
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.