我是 jqGrid 编程的新手。我正在使用带有添加、编辑和重新加载网格功能的内联编辑 jQgrid。当我进入页面时,网格已成功加载。但是在单击重新加载网格按钮后,网格中的所有数据都会消失。最糟糕的部分是单击后,它不是使 Ajax 调用 Web 服务的事件。我浏览了代码,但我的代码没有发现任何错误。下面我给出了我的整个 jqgrid 代码,请参考并让我知道我哪里出错了。
function RenderOGPGrid() {
var oGrid = $('#tbOGP'), lastSel;
var topPagerSelector = '#' + $.jgrid.jqID(oGrid[0].id) + "_toppager";
oGrid.jqGrid({
url: sRelativePath + '/WSAjax.asmx/GetDataForGrid',
mtype: 'POST',
datatype: 'json',
ajaxGridOptions: {
contentType: "application/json; charset=utf-8"
},
serializeGridData: function (data) {
return JSON.stringify(data);
},
jsonReader: {
root: "d.rows",
page: "d.page",
total: "d.total",
records: "d.records"
},
onSelectRow: function (rowid) {
if (rowid && rowid != lastSel) {
if (typeof lastSel !== "undefined") {
$(this).jqGrid('restoreRow', lastSel);
}
lastSel = rowid;
}
updateButtonState($(this));
},
colNames: ['Id', 'Name', 'Age'],
colModel: [
{ name: 'Id', index: 'Id', width: 30},
{ name: 'Name', index: 'Name', width: 30},
{ name: 'Age', index: 'Age', width: 30},
],
prmNames: { page: "pageIndex", rows: "pageSize", sort: "sortIndex", order: "sortDirection", search: "_search" },
autowidth: true,
search: false,
postData: {
filters: null,
spName: 'GetOutwardGPList',
paramXML: ""
},
width: 'auto',
height: 'auto',
rowNum: 20,
rowList: [20, 50, 100, 150, 200],
sortname: "",
sortorder: "asc",
page: 1,
gridview: true,
autoencode: true,
viewrecords: true,
ignoreCase: true,
toppager: true,
footerrow: true,
editurl: 'clientArray',
gridComplete: function () {
$("#tbOGP").setGridParam({ datatype: 'local' });
$("table#tbOGP tr:last").addClass('ireg-jqgrid-lastrow');
$("tr.footrow td").addClass('ireg-jqgrid-lastrow').addClass('ireg-jqgrid-footer');
recalculateWidthInPercent('container', 'tbOGP', 0.96);
},
loadComplete: function () {
updateButtonState($(this));
},
caption: 'Outward Gate Pass List'
}).jqGrid('navGrid', topPagerSelector, {
add: false,
edit: false,
del: false,
search: false
//TckNo. iReg-444(DF01): Removed property refresh: false
}, {}, {}, {}, {}, {}).
jqGrid('inlineNav', topPagerSelector, {
addParams: {
useDefValues: true,
addRowParams: {
oneditfunc: function (rowid) {
updateButtonState($(this));
},
aftersavefunc: function (rowid, response) {
updateButtonState($(this));
},
afterrestorefunc: function () {
updateButtonState($(this));
}
}
},
editParams: myEditParams
});
}