禁用光滑网格中的特定单元格编辑

Disabling specific cell edit in Slick grid

本文关键字:单元格 编辑 网格      更新时间:2023-09-26

有没有办法禁用单元格进行编辑?我们可以在列级别定义编辑器,但是我们可以为特定行禁用该编辑器吗?

grid.onBeforeEditCell.subscribe(function(e,args) {
  if (!isCellEditable(args.row, args.cell, args.item)) {
    return false;
  }
});

您可以禁用甚至更改编辑器/格式化程序/验证器...或使用getItemMetadata方法的其他单元格属性。这里有非常好的文档。
例:

$scope.data.data.getItemMetadata = function (row) {
  var item = $scope.data.data.getItem(row);
  if (item.some_condition) {
    return {
      columns : {
        yourColumnId : {
          editor : null,
          formatter : function () { return 'custom formater if some_condition'; }
        }
      }
    };
  }
};