如果我正确理解您的问题,您应该不要使用选项cellEdit: true(但仍使用cellsubmit: 'remote')并设置cellEdit: true动态 在调用单元格编辑方法之前(editCell、restoreCell、saveCell、prevCell 或 nextCell)。此外,您将不得不复制键盘操作(请参阅免费 jqGrid 代码的the lines)。生成的代码可能如下所示:
ondblClickRow: function (rowid, iRow, iCol, e) {
var $self = $(this), p = $self.jqGrid("getGridParam");
p.cellEdit = true;
$self.jqGrid("editCell", iRow, iCol, true);
p.cellEdit = false;
},
afterEditCell: function (rowid, cmName, cellValue, iRow, iCol) {
var getTdByColumnIndex = function (tr, iCol) {
var $t = this, frozenRows = $t.grid.fbRows;
tr = frozenRows != null && frozenRows[0].cells.length > iCol ?
frozenRows[tr.rowIndex] : tr;
return tr != null && tr.cells != null ? $(tr.cells[iCol]) : $();
},
$td = getTdByColumnIndex.call(this, this.rows[iRow], iCol),
$self = $(this),
$t = this,
p = $self.jqGrid("getGridParam");
$("input, select, textarea", $td).on("keydown", function (e) {
if (e.keyCode === 27) { //ESC
p.cellEdit = true;
$self.jqGrid("restoreCell", iRow, iCol);
p.cellEdit = false;
} else if (e.keyCode === 13 && !e.shiftKey) { //Enter
p.cellEdit = true;
$self.jqGrid("saveCell", iRow, iCol);
p.cellEdit = false;
return false;
} else if (e.keyCode === 9) {
if (!$t.grid.hDiv.loading) {
p.cellEdit = true;
if (e.shiftKey) {
$self.jqGrid("prevCell", iRow, iCol); //Shift TAb
} else {
$self.jqGrid("nextCell", iRow, iCol); //Tab
}
p.cellEdit = false;
} else {
return false;
}
}
e.stopPropagation();
});
}
见https://jsfiddle.net/OlegKi/Lm7akxz2/