【问题标题】:jqgrid - items per pagejqgrid - 每页的项目
【发布时间】:2011-06-16 19:03:31
【问题描述】:

我无法为 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 个元素。为什么?

【问题讨论】:

  • 默认设置为20,你要根据你的数据来设置。
  • 对,rowNum 选项默认为20

标签: jquery asp.net-mvc jqgrid


【解决方案1】:

查看rowNum 选项。来自文档:

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

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-21
    • 1970-01-01
    • 1970-01-01
    • 2017-02-11
    • 2012-03-07
    • 1970-01-01
    • 1970-01-01
    • 2018-03-18
    相关资源
    最近更新 更多