0

我正在使用以下代码构建一个 jqgrid:

  $(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);
    }
}
            });
        });

这工作得很好。但是,这一切都发生在客户端。我也在使用 loadonce:true 到网格,这意味着网格一次加载所有数据。

但是,我有大约 30,000 条记录。

 loadonce=true 

这不是一个正确的选择。所以,我需要实现服务器端排序和服务器端分页。

我需要逐页加载记录,但排序/过滤应该考虑到所有记录。

请对此提供帮助。如果可能,请提供 C# 代码的代码示例和用于分页和排序的 Jquery 脚本。

4

0 回答 0