0

In Angular UI-Grid table, I have one date column (referenceDate) which I want to enable/disable edit based of a flag called 'allowed' which is part of the row value.

How to pass this row value in 'enableCellEdit' attribute ?

Here is my code fragment. I tried with 'row.entity.allowed' but it did not worked. And got error Error: row is not defined

$scope.gridOptions.columnDefs = [ 
    {
        field : "referenceDate", width : "15%", enableCellEdit: row.entity.allowed, type: 'date', cellFilter: 'date:"yyyy-MM-dd"',
    }, 
    {
        field : "manuallyUpdated", width : "10%", cellEditableCondition: false, cellTemplate: '<input type="checkbox" ng-model="row.entity.manuallyUpdated" disabled="true" style="zoom:1.5" >'
    }
];

JSON data

{
    "referenceDate": "2015-09-30",
    "allowed": true,
    "manuallyUpdated": true
}
Rob
  • 14,746
  • 28
  • 47
  • 65
Jay
  • 9,189
  • 12
  • 56
  • 96

1 Answers1

2

Basically, you are not able to access the external scope when setting a value for enableCellEdit.
You should make use of cellEditableCondition and pass it a function like this -

function($scope){
  return $scope.row.entity.allowed;
}

From the docs :

If specified, either a value or function evaluated before editing cell. If falsy, then editing of cell is not allowed.

Pratik Bhat
  • 7,166
  • 2
  • 35
  • 57