I have a mvcjqgrid:
@(Html.Grid("dataGrid")
.SetJsonReader(new MvcJqGrid.DataReaders.JsonReader { Id = "Id", RepeatItems = false })
.SetRequestType(RequestType.Post)
.AddColumn(new Column("Name").SetLabel("Name").SetSearch(true))
.AddColumn(new Column("Email").SetLabel("E-Mail").SetSearch(true).SetFormatter(Formatters.Email))
.AddColumn(new Column("Phone").SetLabel("Phone").SetSearch(true))
.SetSearchToolbar(true)
.SetUrl(Url.Action("GetData", "Controller"))
.SetSearchOnEnter(false)
.SetRowNum(10)
.SetRowList(new[] { 10, 15, 20, 50 })
.SetViewRecords(true)
.SetPager("pager"))
and controller:
public ActionResult GetData()
{
return View(new myEntity[0]);
}
[HttpPost]
public JsonResult GetData(GridSettings gridSettings)
{
int totalRecords = DataHelper.GetCount();
var data = DataHelper.GetData(gridSettings);
var jsonData = new
{
total = totalRecords / gridSettings.PageSize + 1,
page = gridSettings.PageIndex,
records = totalRecords,
rows = data
};
return Json(jsonData);
}
EDIT:
so my question is how can i store GridSettings in session in right way, i need every time user backs to this page, page should be the same as when he left?
If i do:
Session["settings"] = gridSettings;
i need some way to compare stored gridSettings with the one passed to action.