这是我的代码:
<table id="employees"><tr><td></td></tr></table>
<div id="pager"></div>
<script type="text/javascript">
jQuery("#employees").jqGrid({
datatype: "local",
height: 250,
colNames: ['Employee #', 'Name', 'Trade'],
colModel: [
{ name: 'num', index: 'num', width: 100, sorttype: "int" },
{ name: 'name', index: 'name', width: 300 },
{ name: 'trade', index: 'trade', width: 80 },
],
multiselect: true,
pager: '#pager',
rowNum: 10,
rowList: [10, 20, 30],
sortname: "num",
sortorder: "desc",
scroll: false,
viewrecords: true,
autoencode: true,
height: 'auto',
caption: "Equipment"
});
var mydata = [
{ num: "492", name: "Doug Anderson", trade: "WS" },
{ num: "696", name: "William Anderson", trade: "OP" },
{ num: "826", name: "Chris Autry", trade: "WF" },
{ num: "206", name: "Tom Beffa", trade: "OP" },
{ num: "799", name: "Glenn Bixler", trade: "LB" },
{ num: "360", name: "Pete Bober", trade: "OP" },
{ num: "7", name: "Scott Burgie", trade: "PFW" },
{ num: "476", name: "James Click", trade: "W" },
{ num: "775", name: "Bryan Darst", trade: "LB" },
{ num: "249", name: "Bob Dunham", trade: "LB" },
{ num: "10", name: "Tom Ekclund", trade: "WGF" },
{ num: "390", name: "Noel Edwards", trade: "W" }
];
for (var i = 0; i <= mydata.length; i++)
jQuery("#employees").jqGrid('addRowData', i + 1, mydata[i]);
</script>
我的问题是寻呼机显示,但显示“0 中的 1”,然后只显示所有行而不是 10 行。奇怪的是,如果我在页面加载后更改排序列,或更改行数显示,它开始正常工作。例如,如果我加载页面并将显示的行数切换为 20,它会在底部显示“1 out of 1”,然后如果我将其设置回 10,我将有 2 个页面可以切换。我只是不明白为什么它在页面加载后不能立即工作。