jqgrid - 每页的项目

时间:2011-06-16 19:03:32

标签: jquery asp.net-mvc 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: ""
            },

...

和MVC方法返回:

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

        return result;

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

1 个答案:

答案 0 :(得分:11)

查看rowNum选项。来自文档:

  

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

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

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

jQuery('#EmployeeTable').jqGrid({
        url: '/Admin/IdeasJSON',
        ...
        rowNum: 50,
相关问题