Ticket Q553684
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

GridView - Provide the capability to apply saved cookies automatically when a custom binding is used

How to obtain the grid view model on the FIRST call when Cookies are enabled

created 11 years ago

Hi,

I'm using custom model binding on my grid and the grid have cookies enabled:

settings.SettingsCookies.Enabled = true; settings.SettingsCookies.StoreFiltering = true;

when I browse to a page on the grid the result it's fine.

The problem born when I leave the page and return to it or when I simply refresh the page on the browser, if I do this the grid show the right page but not the content, the data in the grid ever correspond to the first page

The action called is:

C#
public ActionResult GridPartialView(){ GridViewModel viewModel = GridViewExtension.GetViewModel("myGridView"); if (viewModel == null) //Initialize the grid state on the first load viewModel = CreateGridViewModel(); return MyCustomBindingCore(viewModel); }
C#
static GridViewModel CreateGridViewModel(){ var viewModel = new GridViewModel(); viewModel.KeyFieldName = "Id"; viewModel.Columns.Add("Column1"); viewModel.Columns.Add("Column2"); viewModel.Columns.Add("Column3"); viewModel.Columns.Add("Column4"); viewModel.Columns.Add("Column5"); viewModel.Columns.Add("Column6"); return viewModel; }
C#
PartialViewResult MyCustomBindingCore(GridViewModel gridViewModel){ //Delegate implementation of the functions that are always required for custom binding gridViewModel.ProcessCustomBinding( MyBindingHandlers.MyGetDataRowCount, //Function to return the total number of data rows in a model MyBindingHandlers.MyGetData //Function to return data rows requested by the grid ); return PartialView("GridPartialView", gridViewModel); }

I check the viewModel and it is always null so the code create a new one and both: the pager.PageIndex are 0 and pager.PageSize are 10 allways.

why if the cookies are enabled the viewModel is null?

how is the rigth way to recover the cookie's values for the viewModel?

Once I make this work I need add filter and group to the grid ¿will I have the same issue with these values?

May be I'm totally wrong

Thanks for your help.

Greetings,

Carlos.

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

Hello Carlos,
Currently, saving the state in cookies is not supported when the custom binding mode is used. We have the GridView - Provide the capability to apply saved cookies automatically when a custom binding is used ticket regarding it. I suggest that you use the ClientLayout event instead. Please refer to the GridView - Custom Binding - Provide a method that will allow applying saved client layout to the GridViewModel object ticket that illustrates this approach.

    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.