the most common request we get when it comes to our (rather heavy) use of RadGrid is to allow users to save which columns are visible on the grid (when we allow users to show/hide columns using the contextheader.)
What would be the best method to do this? Is RadPersistenceFramework overkill (does it even allow this?)
3 Answers, 1 is accepted
As demonstrated in the following online demo, the RadPersistenceManager will store the visibility of the columns when you use the HeaderContextMenu for hiding/showing the columns and after you click on the Save button:
Although that the demo does not match your exact requirement, you can easily modify it. What you will have to do is to save the state of the grid after you hide or show a column through the HeaderContextMenu. In order to do that you could handle the client-side OnColumnShown and OnColumnHidden events and initiate a postback where you could save the grid state through the RadPersistanceManager. However, this approach will initiate a postback on each column action, so it is not user friendly.
For your convenience, following is a very simple example demonstrating how to achieve the same by handling the Hidden event of the RadContextMenu and initiate a postback through a hidden RadButton:
And the code-behind:
Hope this helps.
thank you for your time.
will this method store ALL RadGrid settings (so if the grid is on page 2 and sorted those will be saved w/ the column visibility?)
The approach from my example will store all settings in the control. If you need to remove some of the settings (or all of them) and include only particular one you could take a look at the following help article: