JQgrid:选择整行与单击的单元格

JQgrid: Picking the entire row vs clicked cell

这是 @Oleg 制作的两个不同的表格:

first 上,单击单个单元格时 - 整行都被选中。

second 上,只有单击的单元格被选中。

这是由 cellEdit: true 控制的。

我想要一个将 cellEdit 设置为 false 的逻辑,但仅限于某些行(在某些情况下,为简单起见,假设单元格的值低于 100 时会发生这种情况) .

如何实现?

要允许编辑某些列中的数据,必须在列中指定 editable 属性。 Free jqGrid allows to use callback function as the value of editable property. The callback should return boolean value, which informs jqGrid, whether the cell is editable or not. The wiki article 更详细地描述了该功能。例如,仅当 amount 列中的值小于 100 时,某些列 colModel 中的以下回调才允许编辑单元格:

editable: function (options) {
    var item = $(this).jqGrid("getLocalRow", options.rowid);
    if (item.amount < 100) {
        return false;
    }
    return true;
}