kaz*_*aze 2 javascript jquery jqgrid
当在CellEdit之前捕获事件时,是否有可能以某种方式阻止单元格进入编辑模式?
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 });
}
Run Code Online (Sandbox Code Playgroud)
触发事件,但列属性的设置似乎不会更改编辑模式.
该方法beforeEditCell将在编辑过程中调用.它主要用于在新创建的输入或选择元素中进行一些初始化.
如果您需要在单元格编辑模式下阻止某些单元格进行编辑,我会建议您"not-editable-cell"有时在单元格中设置类(例如在cellattr或中loadComplete)或者用于beforeSelectRow返回false某些单元格.它beforeSelectRow返回false,单元格将不会编辑.
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
}
}
Run Code Online (Sandbox Code Playgroud)