So I have been looking around the interwebs on how to store an EXT paging grid state on my server so that when users login back in their grid it is how they saved it.
I found this http://www.sencha.com/forum/showthread.php?64688-How-can-i-save-Grid-state-using-GXT but it is an old and dead thread.
What I have right now is:
grid.getState() returns a map of all col sizes, sorts, and hidden fields.
here is an example dumped to string:
{offset=0, limit=25, widthfieldname1=161, widthfield2=110, hiddenfield3=true }
I could store these key/values in a simple table with fields (username, key, value) and recreate this map and pass it to the front end.
So here is my question:
Does anyone have a code example of a full implementation of storing, retrieving and apply a grid state for GXT 2.4?
If not. How would I go about implementing one? I am confident i could store the state map in the database or XML. I am lost on how to apply this to a new session. How do i apply this state map to a new grid?
State management is already build into many components, and also into grids.
Default GXT implementation uses Cookies (take a look at the
com.extjs.gxt.ui.client.state.CookieProvider) to store Grid’s state, you just need make the grid statefull and give it a unique stateId:If other storage is required, then you need to extend
com.extjs.gxt.ui.client.state.Provider, implement you store/load logic and then pass it tocom.extjs.gxt.ui.client.state.StateManager, it’s going to be pretty straightforward:Please also note that State Management is changed in GXT3, you should keep it in mind if you need to migrate to 3.0 at the nearest future.