【发布时间】:2013-05-01 22:40:09
【问题描述】:
我正在使用 jqGrid 中的行编辑工具进行内联编辑,然后将数据保存在网格中(即,对 url 使用“clientArray”)。我正在使用“onSelectRow”函数将选择行置于编辑模式。
当通过保存按钮保存行时,此逻辑可以正常工作,但是当在第一行仍处于编辑模式时单击另一行时,为第一行调用 saveRow 函数不会保存更改,并且该行字段恢复为之前的值。
我已经尝试过使用和不使用“beforeSelectRow”功能。在这种情况下如何正确保存行更改?
逻辑如下:
var iRow;
...
beforeSelectRow: function (id, e) {
if (id != null) {
if (iRow != null && iRow != id) {
SaveRow();
}
}
return true;
},
onSelectRow: function (id, status, e) {
if (id != null) {
if (iRow != null && iRow != id) {
SaveRow();
}
if (iRow == null) {
iRow = id;
$("#GridMain").jqGrid("editRow", id, false);
$("#RowPanel").show();
}
}
}
function SaveRow() {
// Save the current row if it was being edited
if (iRow != null) {
$("#GridMain").jqGrid("saveRow", iRow, { url: "clientArray" });
$("#RowPanel").hide();
iRow = null;
}
}
【问题讨论】:
标签: jqgrid