c# - MVCjqDrid store GridSettings in session -
i have 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:
question how can store gridsettings in session in right way, need every time user backs page, page should same when left?
if do:
session["settings"] = gridsettings;
i need way compare stored gridsettings 1 passed action.
why don't use http cache case? can write caching provider, , http cache 1 implementation this. in future can extend more providers it.
Comments
Post a Comment