PDA

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



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


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?

pscanlon1
4 Apr 2013, 11:11 AM
Look at http://localhost/extjs/ext-4.2.0.663/docs/index.html#!/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();

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

http://www.sencha.com/forum/showthread.php?141207