i'm trying to implement paging for jqGrid. but it's not clear if i can do it using generic handlers in asp.net?
my grid looks like this:
layout:
<table id="userGrid" ></table>
<div id="userGridPager"></div>
script:
grid = $("#userGrid");
grid.jqGrid({
url: 'http://localhost/MyApp/MyHandler.ashx',
datatype: "json",
colNames: ['Id', 'Name', 'Account', 'Deleted', 'Timer'],
colModel: [
{ name: 'Id', index: 'Id', width: 50, stype: 'text', key: true },
{ name: 'Name', index: 'Name', width: 150, editable: true},
{ name: 'Account', index: 'Account', width: 50, editable: false },
{ name: 'Deleted', index: 'Deleted', width: 50, editable: true, sortable: false, align: 'center', edittype: 'checkbox', editoptions: { value: "True:False" }, formatter: "checkbox", formatoptions: {disabled : false} },
{ name: 'Timer', index: 'Timer', width: 80, align: "right", editable: true }
],
rowNum: 15,
mtype: 'GET',
pager: '#userGridPager',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption: "Users",
height: "100%"
});
MyHandler.ashx:
public class MyHandler: IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// how can i get here page number?
var users = User.GetAllUsers(); // it's necessary to pass page number and page size to this function
var jsonSerializer = new JavaScriptSerializer();
context.Response.Write(jsonSerializer.Serialize(users));
}
}
i understand that i need to pass my data to client so that it will contain page, total, records for jsonReader, but i don't understand how to get page number in habdler. does anybody know the answer?