PDA

View Full Version : serialize data and state of a form/grid



varsos
24 Nov 2008, 7:04 AM
I have an application that has a very complex layout, 3-4 large forms, 1 editorgrid, 3-4 grids,
many panels and tabs. The whole set, lives under a tab.
I create multiple instances of this complex UI, with different data.

Since it is expensive to create and destroy this UI, I was looking into ways of creating it once,
and then swapping the data and internal state with another set of data, instead of creating a whole new set of objects.
I only show one at a time, so there isn't really a reason for having a new set of objects.

To do this I am thinking of some sort of "serializing" of the data in the forms and grids,
including the state like modified records, etc., storing the data in a cache,
and using it to re-load the forms and grids, and bring it back to the previous state.
The data may have or have not been saved when the swap occurs.

Also,I would not want to change any config options, upon "re-loading"
I only need to swap the data and any required "state" of the components.
By state I mean internal special data that is kept by some components.

Here is an example:

To swap out the data for a grid and swap in a new set, i need to do:

1. serialize the store (data, snapshot, modified records, baseParams, sortInfo, etc)
2. serialize the selections in a selection model, but just the ids
3. serialize the columnModel (config object), in case the columns were removed, re-arranged, etc.
4. serialize the "cursor" of the paging bar.

When all of this is saved, upon restore, I would want to put all that back, and the grid should be the same way it was.

Any examples of how to "serialize" a grid/form to a JSON object, with its internal state, would be appreciated.

I know I have to write code to do all this, but I was wandering if I am on the right track.

Thanks