【发布时间】:2012-03-04 03:16:22
【问题描述】:
在这里附加类似的问题,但我找不到我的答案:
在 html 中是 table id=grid 和 div id=pager:
还有我的js代码:
var myGrid = $("#grid").jqGrid({
url: _options.gridFetch,
datatype: "json",
colModel:[
{name:'id',index:'id', width:55},
{name:'name',index:'name', width:555, editable:true},
{name:'is_promoted',index:'is_promoted', width:165, editable:true, formatter: $.adminCategoryEntries._boolFormatter, edittype: 'select', editoptions:{value:"1:Yes;0:No"}},
{name:'is_in_shop',index:'is_in_shop', width:165, editable:true, formatter: $.adminCategoryEntries._boolFormatter, edittype: 'select', editoptions:{value:"1:Yes;0:No"}},
{name:'actions', formatter:'actions', width: 85, formatoptions:{keys:true}},
],
pager: '#pager',
jsonReader : { repeatitems: false } ,
rowNum: 10,
rowList: [10, 20, 500],
viewrecords: true,
autowidth: true,
sortname: 'id',
sortorder: 'desc'
});
myGrid.jqGrid('navGrid','#pager',{edit:false,add:false,del:false,search:false});
我使用了其他 stackoverflow 教程中的代码。
这是我的问题:如果我尝试更改导航器中显示的行数,我可以看到所有存储的数据(86 行),但如果我将行设置为每页 10(值小于行数),我总是在我的导航器中查看:
第 1 页,共 5 页
我无法将它切换到另一个它总是首先保持打开
json 信息:
>page: 1
>records: "86"
>rows: [{id:3, name:Ulkofilee/Naudanliha, is_promoted:1, is_in_shop:1},…]
>total: 5
提前致谢 拉德克
【问题讨论】:
-
我已经编辑了 edmy 问题
-
如果你返回 total: 5 那么 jqGrid 显示“page 1 of 5”。您应该只根据输入
rows参数计算total值,该参数表示每页的行数。例如,如果行等于 28,则应将 3 作为total值。 -
看看the old answer 我试图描述 jqGrid 如何使用 JSON 响应中的“total”、“page”和“records”属性。如果您在服务器端实现服务器端分页时遇到问题,您可以在 JSON 响应中返回 所有数据 并使用
loadonce: truejqGrid 选项。如果数据的分页、排序和过滤将在本地实现。 -
非常感谢您的帮助,现在一切正常
标签: javascript jquery jqgrid