Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling specific cell edit in Slick grid

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?

like image 768
emphaticsunshine Avatar asked May 08 '12 02:05

emphaticsunshine


2 Answers

grid.onBeforeEditCell.subscribe(function(e,args) {
  if (!isCellEditable(args.row, args.cell, args.item)) {
    return false;
  }
});
like image 70
Tin Avatar answered Nov 13 '22 14:11

Tin


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'; }
        }
      }
    };
  }
};
like image 20
icl7126 Avatar answered Nov 13 '22 16:11

icl7126