jqgrid-每页项目 [英] jqgrid - items per page

查看:85
本文介绍了jqgrid-每页项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I can't configure items per page for jqgrid. My jqgrid is:

        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个元素.为什么?

where IdeaForJSONs has 50 elements. I don't know why but grid shows 20 elements. Why?

推荐答案

看看 rowNum 选项.从文档中:

Have a look at the rowNum option. From the documentation:

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

Sets how many records we want to view in the grid. This parameter is passed to the url for use by the server routine retrieving the data. Note that if you set this parameter to 10 (i.e. retrieve 10 records) and your server return 15 then only 10 records will be loaded.

默认值为20,这说明了为什么只看到这么多行.

The default value is 20, which explains why you are only seeing this many rows.

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

If you increase it to 50 you should see all of your data in the grid:

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

这篇关于jqgrid-每页项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆