Persists style between posts

nettech

New member
Joined
Jun 20, 2007
Messages
4
Programming Experience
Beginner
I create my WebGrid columns programatically. I set typical settings like column order, width, type,
filtering, sorting, and grouping. The user is then able to modify this standard layout to suit their
needs as they please.

I would like to know how i can then save the changes made to the layout of the grid, so next time they
visit the page it loads with the same layout settings as they left it. This would be a very useful
feature as it enables the user to set the layout of the grid in a particular way they like to view
the displayed data every time they visit a particular page.

Please provide a sample on how to implement such functionality. I have investigated using
SaveTablesStructureToXml, and LoadTablesStructureFromXml without a lot of luck. The method
used to save and load should be transparent to the user i.e. should happen in the background
without them needing to click a save or load button.

When you have saved the layout in a file, but add another column to the grid, the column is
still added when the layout is restored. This behaviour is desired. However, when you have
a saved layout, but remove a column from the grid, when the layout is restored, the column
is still added. How can we ensure that columns removed from the grid are not displayed even
though they are still contained in the saved layout definition?

The InitializePostBack event does not fire when things like SelectColumns, changing column
widths, expanding group rows etc are changed. The only way to save the layout when these
types of events occur is to capture the client side event and use SendCustomRequest to
fire the InitialisePostBack event on the server. Is this correct? or is there another
way that will handle all cases? I'm not sure i will want to handle all events as latency
could become an issue, but this may be a requirement in the future.

Please give me sample on how to do it?
 
Back
Top