23 Jan 2013 3:03 AM #1
How-to store the Grid-State
I want to store/restore the column width, sort-order and column visibility from a Grid. After some searching around i found some answers which describe StateManager and applyState. For example a thread on 16 Oct 2012;
"How to work with StateManager gxt 3"
Within the 'best answer' Colin already switches from a 'standard' to a custom technique;
And instead of this last step, consider just extending the AbstractStateHandler, and implementing your own applyState() method to modify the object that has this state. Build any handlers required then, to modify the contents of getObject() - notice that you can't replace the instance (in short: autobeans dont really work well like that), but you can modify any other object in it.
23 Jan 2013 8:44 AM #2
The linked question is more about building wiring to ask questions about state for a new component, while your question seems more about how to persist any/all state in a custom way.
When you write your own component that needs its own kind of state, start with the AbstractStateHandler to read and write state details from whatever abstraction the entire app is using.
When you want to describe how the entire app should read and write all state details, implement a com.sencha.gxt.state.client.Provider instance. We don't have a 'standard procedure' for this that mandates a specific database, driver, servlet, but instead offer this abstract class to work from. Just like DataProxy, there are several subclasses to work from: com.sencha.gxt.state.client.AbstractRpcProvider is probably the most familiar if you already use RPC.