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.