Ticket S172523
Visible to All Users

GridView - Custom Binding - Provide a method that will allow applying saved client layout to the GridViewModel object

created 11 years ago

As a workaround, it is possible to use the approach from the GridView - How to load saved Client Layout data in Custom Model Binding mode ticket. Additionally, it is necessary to manually obtain the filter expression from your saved layout and apply it to the GridViewModel object in the controller. For example, if we open the Advanced Custom Binding demo, this should be done in the AdvancedCustomBindingPartial method:
View:

C#
settings.ClientLayout = (s, e) => { if (e.LayoutMode == ClientLayoutMode.Saving) { Session["gvSettings"] = e.LayoutData; } else { if (Session["gvSettings"] != null) { e.LayoutData = Session["gvSettings"].ToString(); } } }; settings.ClientSideEvents.Init = "function(s, e) { s.PerformCallback(); }";

Controller:

C#
public ActionResult AdvancedCustomBindingPartial() { var viewModel = GridViewExtension.GetViewModel("gridView"); if (viewModel == null) viewModel = CreateGridViewModelWithSummary(); if (string.IsNullOrEmpty(viewModel.FilterExpression) && Session["gvSettings"] != null) { // Session["gvSettings"] stores the client layout var filterParams = Session["gvSettings"] .ToString() .Split('|') .ToList(); var lengthParam = filterParams.Where(x => x.StartsWith("filter")).SingleOrDefault(); if (!string.IsNullOrEmpty(lengthParam)) { var index = filterParams.IndexOf(lengthParam); var savedFilterExpression = filterParams[index + 1]; viewModel.FilterExpression = savedFilterExpression; } } return AdvancedCustomBindingCore(viewModel); }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.