How to do server side Sorting/Paging in jqgrid in ASP.net MVC

為{幸葍}努か 提交于 2019-12-25 04:39:09

问题


I am constructing a jqgrid with the following code:

  $(document).ready(function () {
            $("#Data").jqGrid({
                url: '/Home/LoadData',
                loadonce:true,
                datatype: "json",
                mtype: "GET",
                colNames:["ID"],
                colModel: [
            { name: "Id",index:'ID',width:800, align: "center"}
                          ],
                pager: "#Pager",
                rowNum: '10',
                rowList: [10, 20, 30],
                sortname: "ID",
                sortorder: "asc",
                height: "auto",
                gridview:true,
                sortname: "ID",
                viewrecords: true,
                caption: "My First Grid",
                loadComplete: function (data) {
    var $this = $(this),
        datatype = $this.getGridParam('datatype');

    if (datatype === "xml" || datatype === "json") {
        setTimeout(function () {
            $this.trigger("reloadGrid");
        }, 100);
    }
}
            });
        });

This is working absolutely fine. But, this is all happening in the client side. I am also using loadonce:true to the grid which means the grid loads all the data at once.

But, i am having approx 30,000 records.

 loadonce=true 

This is not an correct option. So, i need to implement server side sorting and server side paging.

I need to load records like page by page but sorting/Filtering should happen taking into consideration all the records.

Please help in this..if possible please provide code sample for C# code and Jquery script for paging and sorting..

来源:https://stackoverflow.com/questions/19313780/how-to-do-server-side-sorting-paging-in-jqgrid-in-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!