如何将行字段值传递给 'enableCellEdit' 属性?

How to pass a row field value to 'enableCellEdit' attribute?

在 Angular UI-Grid table 中,我有一个日期列 (referenceDate),我想 enable/disable 根据名为 'allowed' 是行值的一部分。

如何在 'enableCellEdit' 属性中传递此行值?

这是我的代码片段。 我尝试使用 'row.entity.allowed' 但它没有用。并得到错误 错误:未定义行

$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数据

{
    "referenceDate": "2015-09-30",
    "allowed": true,
    "manuallyUpdated": true
}

基本上,在为 enableCellEdit 设置值时,您无法访问外部范围。
你应该使用 cellEditableCondition 并传递给它一个像这样的函数 -

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

来自文档:

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