我在这里有一个带有 jqGrid 的 jsfiddle:
http://jsfiddle.net/yNw3C/3953/
var data = [[48803, "DSK1", "", "02200220", "OPEN"], [48769, "APPR", "", "77733337", "ENTERED"]];
$("#grid").jqGrid({
datatype: "local",
autowidth: true,
toppager: true,
scroll: 1,
colNames: ['Inv No', 'Thingy', 'Blank', 'Number', 'Status'],
viewrecords: true,
colModel: [{
name: 'id',
index: 'id',
width: 60,
sorttype: "int"},
{
name: 'thingy',
index: 'thingy',
width: 90,
sorttype: "date"},
{
name: 'blank',
index: 'blank',
width: 30},
{
name: 'number',
index: 'number',
width: 80,
sorttype: "float"},
{
name: 'status',
index: 'status',
width: 80,
sorttype: "float"}
],
caption: "Stack Overflow Example",
});
var names = ["id", "thingy", "blank", "number", "status"];
var mydata = [];
for (var i = 0; i < data.length; i++) {
mydata[i] = {};
for (var j = 0; j < data[i].length; j++) {
mydata[i][names[j]] = data[i][j];
}
}
for (var i = 0; i <= mydata.length; i++) {
$("#grid").jqGrid('addRowData', i + 1, mydata[i]);
}
var pager = '#grid_toppager';
$("#grid").jqGrid('navGrid', pager, {refresh: true, search:false, edit: false, view:false, del: false, add: false, position: 'right'})
.navButtonAdd(pager, {
buttonicon: "ui-icon-newwin",
onClickButton: null,
position: "last",
title: "",
cursor: "pointer",
caption: ""
});
如果您看一下第 54 行,您会看到我将导航网格的“位置”设置为右侧。按钮完全消失了。如果我将其设置为“左”或“中心”,它们似乎按预期工作。
难道我做错了什么?或者这是 jqGrid 中的一个合法错误?顺便说一句,我确实需要保持“toppager”和“scroll”元素原样。