View Full Version : How to Save and Retrieve Grid format in Database

3 Apr 2013, 2:47 AM
I am having a grid panel.
I need to save and retrieve the hidden state, width, order and sort state of the grid columns.
I have set the grid's property stateId and stateful to true.

I am able to set it by adding the following code in controller's init function

The above one is saving and retrieving data from browser Cookies.
In the same way, how can i save and retrieve it from the database?

Can you please someone tell me how to do this?

4 Apr 2013, 11:11 AM
Look at http://localhost/extjs/ext-!/api/Ext.state.CookieProvider

You really have 2 methods, get and set to be concerned with.

set is called when the state changes, and you can see in the cookieProvider that they set a cookie for the state of the object. You could add an AJAX call within the set method to persist to DB, save to a localStorage store, and sync the localstorage store,save to memory store and sync that with DB. The get method you override should read from whereever you decide to save the information to. THe constructor should load the state from the database, which would be in the same spot as

me.state = me.readCookies();

4 Apr 2013, 3:44 PM
You might also check out this ux to see how another community member addresses the state provider on the server side.