Disabling specific cell edit in Slick grid

两盒软妹~` 提交于 2019-12-05 11:24:57

问题


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?


回答1:


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



回答2:


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'; }
        }
      }
    };
  }
};


来源:https://stackoverflow.com/questions/10491676/disabling-specific-cell-edit-in-slick-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!