Skip to content

Handle the grid's ClientLayout event to save and restore the grid's client layout. The modified layouts are stored in a session.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/asp-net-mvc-grid-save-restore-client-layout-within-a-session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for ASP.NET MVC - How to save and restore client layout within a session

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.

Save and restore client layout

Overview

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()

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Handle the grid's ClientLayout event to save and restore the grid's client layout. The modified layouts are stored in a session.

Topics

Resources

License

Stars

Watchers

Forks