17

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?

emphaticsunshine
  • 3,725
  • 5
  • 32
  • 42

2 Answers2

32
grid.onBeforeEditCell.subscribe(function(e,args) {
  if (!isCellEditable(args.row, args.cell, args.item)) {
    return false;
  }
});
Tin
  • 9,082
  • 2
  • 34
  • 32
  • 1
    +1 - A much better solution! I've never used this grid before so I immediately resorted to 'hacking' away at it. [Here's a fiddle](http://jsfiddle.net/R9fMD/4/) to compliment your answer. It simply disables editing in the 4th row. – Brandon Boone May 09 '12 at 02:47
  • Fantastic solution!! I should've thought of it :P – Travis Sharp Mar 03 '16 at 22:38
1

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'; }
        }
      }
    };
  }
};
icl7126
  • 5,740
  • 4
  • 53
  • 51