我试图在保存一行后重新加载网格,以便能够获取行的 Id 以进行记录,但不知何故“aftersavefunc”和“successfunc”在保存之前触发了“reloadGrid(‘#telephoneGrid’)”。似乎“aftersavefunc”和“successfunc”是相同的。现在我无法添加或编辑任何行。
var lastSel;
function onTelephoneSelect(id, status, e) {
if ($(e.target).hasClass('edit')) {
var editParameters = getEditParameters();
if (id && id !== lastSel) {
jQuery('#telephoneGrid').saveRow(lastSel);
}
jQuery("#telephoneGrid").jqGrid('editRow', id, editParameters);
lastSel = id;
}
}
function getEditParameters() {
return {
"keys": true,
"oneditfunc": null,
"successfunc": null,
"url": '@Url.Action("SaveTelephoneEntry","TelephoneEntry")?customerId=' + $('#SelectCompany').val(),
"extraparam": {},
"aftersavefunc": reloadGrid('#telephoneGrid'),
"errorfunc": null,
"afterrestorefunc": null,
"restoreAfterError": true,
"mtype": "POST"
}
}
我现在非常绝望,找不到任何可行的解决方案。
有人可以在这里帮助我,还是已经遇到了同样的问题并找到了可行的解决方案?
非常感谢。
最佳答案
'aftersavefunc' 和 'successfunc' 是回调,但您似乎正试图直接设置该函数,因此它们在您打算之前被调用。
使用正确的回调签名,它应该看起来像这样:
"aftersavefunc": function (rowid, response, options) {
reloadGrid('#telephoneGrid');
},
关于javascript - JqGrid 在 'aftersavefunc' 之前触发 'successfunc' 和 'saveRow',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46560579/