This example demonstrates how to handle the grid's ClientLayout event to save and restore the grid's client layout. The modified layouts are stored in a session.
Handle the grid's server-side ClientLayout event and do the following in the handler:
- Set the LayoutMode argument property to
Saving
to save the current client layout to a session. - Set the LayoutMode argument property to
Loading
to restore the last client layout from the session.
@Html.DevExpress().GridView(settings => {
<!-- ... -->
settings.ClientLayout = (s, e) => {
switch (e.LayoutMode) {
case ClientLayoutMode.Loading:
if (Session["Layout"] != null) {
e.LayoutData = Session["Layout"].ToString();
}
break;
case ClientLayoutMode.Saving:
Session["Layout"] = e.LayoutData;
break;
}
};
}).Bind(Model).GetHtml()
Note that you can use the grid's SettingsCookies property to emulate the same behavior. In this case, the last client layout is stored on the client.
@Html.DevExpress().GridView(settings => {
<!-- ... -->
settings.SettingsCookies.Enabled = true;
}).Bind(Model).GetHtml()
- Grid View for ASP.NET Web Forms - How to use a list box editor to save and restore client layout
- Grid View for ASP.NET MVC - How to use a list box editor to save and restore client layout
(you will be redirected to DevExpress.com to submit your response)