0

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?

4

1 回答 1

0

使用这种方法,您可以在 GET 请求的查询字符串中获得页码,例如

WebApp/MyHanler.ashx?page=2

如何获取查询字符串参数,您可以在此处查看:如何从 ashx 文件中获取 QueryString?

于 2013-10-08T14:14:25.097 回答