Prevent jqGrid from entering edit cell using beforeCellEdit event?
javascript, jqgrid, jquery
Solution
The method `beforeEditCell` will be called in the middle of the editing process. It exist mostly to make some initialization in the new created input or select element.
If you need prevent some cells from editing in the cell editing mode I cen suggest you either to set `"not-editable-cell"` class in the cell sometimes before (for example in `cellattr` or in `loadComplete`) or use `beforeSelectRow` to return `false` for some cells. It `beforeSelectRow` return false the cell will be not editing.
beforeSelectRow: function (rowid, e) {
var $td = $(e.target).closest("td"), iCol = $.jgrid.getCellIndex($td[0]);
if (/* test some rules here */) {
return false; // prevent selection and so the editing of the cell
}
}
Problem
Is it possible to somehow stop the cell from entering edit mode, when catching the event beforeCellEdit? ``` beforeEditCell: function (rowid, cellname, value, irow, icol) { if (cellname != 'aSpecificCol') return; var grid = $("#grid"); if (aCondition == "something") grid.setColProp('aSpecificCol', { editable: false }); else grid.setColProp('aSpecificCol', { editable: true }); } ``` The event fires, but the setting of column property seems to not changing the edit mode.