Back to Devexpress

GridSettingsBase.ClientLayout Property

aspnetmvc-devexpress-dot-web-dot-mvc-dot-gridsettingsbase-edd2c166.md

latest3.3 KB
Original Source

GridSettingsBase.ClientLayout Property

Enables you to save and restore the previously saved layout of the extension.

Namespace : DevExpress.Web.Mvc

Assembly : DevExpress.Web.Mvc5.v25.2.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public ASPxClientLayoutHandler ClientLayout { get; set; }
vb
Public Property ClientLayout As ASPxClientLayoutHandler

Property Value

TypeDescription
ASPxClientLayoutHandler

A ASPxClientLayoutHandler delegate method allowing you to implement custom processing.

|

Remarks

Provide implementation of the delegated method to save and restore the grid’s layout from a data store.

razor
@Html.DevExpress().GridView(settings => {
    // ...
    settings.ClientLayout = (s, e) => {
        switch (e.LayoutMode) {
            case ClientLayoutMode.Loading:
                //Load Last ClientLayout Via First Load
                if (Session["Layout"] != null) {
                    e.LayoutData = Session["Layout"].ToString();
                }
                break;
            case ClientLayoutMode.Saving:
                //Save Last ClientLayout Automatically
                Session["Layout"] = e.LayoutData;
                break;
        }
    };
}).Bind(Model).GetHtml()

Save Layout

The delegated method argument’s LayoutMode property returns Saving. The LayoutData property contains the grid’s current layout that should be saved, for instance, to a database.

Restore Layout

The LayoutMode property returns Loading. Read the grid’s layout data from a data store and assign it to the LayoutData property.

View Example: GridView - How to programmatically Save/Load the last ClientLayout within the SessionView Example: Grid View for ASP.NET MVC - How to use a list box editor to save and restore end-user layouts

Note that there is a peculiarity when using the ClientLayout in custom binding mode. See the GridView Custom Binding Limitations and CardView Custom Binding Limitations topics for more details.

See Also

Grid View

Card View

GridSettingsBase Class

GridSettingsBase Members

DevExpress.Web.Mvc Namespace