Disabling specific cell edit in Slick grid

2020-07-02 08:41发布

Is there a way to disable a cell for editing? We can define editor at column level but can we disable that editor for specific rows?

2条回答
Anthone
2楼-- · 2020-07-02 09:08
grid.onBeforeEditCell.subscribe(function(e,args) {
  if (!isCellEditable(args.row, args.cell, args.item)) {
    return false;
  }
});
查看更多
beautiful°
3楼-- · 2020-07-02 09:19

You can disable or even change editor/formatter/validator... or other cell properties using getItemMetadata method. There is very nice documentation for this here.
Example:

$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'; }
        }
      }
    };
  }
};
查看更多
登录 后发表回答