jqgrid - 每页的项目

Ole*_* Sh 6 asp.net-mvc jquery jqgrid

我无法为jqgrid配置每页的项目.我的jqgrid是:

        jQuery('#EmployeeTable').jqGrid({
            url: '/Admin/IdeasJSON',
            datatype: 'json',
            postData: { page: page, pageIndex: pageIndex, Filter: Filter, DateStart: DateStart, DateEnd: DateEnd, TagID: TagID, StatusID: StatusID, CategoryID: CategoryID, IsDescription: IsDescription },
            loadComplete: function () { pageIndex = null },
            jsonReader: {
                page: "page",
                total: "total",
                records: "records",
                root: "rows",
                repeatitems: false,
                id: ""
            },
Run Code Online (Sandbox Code Playgroud)

....

和MVC方法返回:

        var result = new JsonResult()
        {
            Data = new { page = page, total = total, records = totalCount, rows = IdeaForJSONs }
        };
        result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

        return result;
Run Code Online (Sandbox Code Playgroud)

其中IdeaForJSONs有50个元素.我不知道为什么,但网格显示20个元素.为什么?

Jus*_*ier 11

看看rowNum选项.从文档:

设置我们要在网格中查看的记录数.此参数传递给url以供检索数据的服务器例程使用.请注意,如果将此参数设置为10(即检索10条记录)并且服务器返回15,则只会加载10条记录.

默认值为20,这解释了为什么您只看到这么多行.

如果将其增加到50,您应该会在网格中看到所有数据:

jQuery('#EmployeeTable').jqGrid({
        url: '/Admin/IdeasJSON',
        ...
        rowNum: 50,
Run Code Online (Sandbox Code Playgroud)