ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

cellEditableCondition not disable cell edit

Open yleigh opened this issue 11 years ago • 6 comments

I'm following the ui-grid tutorial. I want ot disable on certain cell editable with boolean; $scope.gridOptions = { enabledColumnResize: true, multiSelect: false, enableRowSelection: false, enableHighlighting: false }; $scope.gridOptions.columnDefs = [ { name:'name', displayName:'Group Name', enableSorting: false, cellEditableCondition: "row.entity.isGroup", cellTemplate: '

{{row.entity.isGroup}} {{row.entity.name}}
'}, ]; ...set data here

However the cell is always double clickable and editable even for "row.entity.isGroup" false. Using rc-16 now.

Appreciate any help

yleigh avatar Dec 12 '14 17:12 yleigh

Is the tutorial working correctly for you - i.e. the tutorial has a column that isn't editable I believe? I suspect it's the way you're defining your cellEditableCondition, have you tried defining it as: cellEditableCondition: row.entity.isGroup?

PaulL1 avatar Dec 12 '14 17:12 PaulL1

Yes, tutorial works for me. If I do it like that, browser won't parse and complains cellEditableCondition: row.entity.isGroup I tried to remove ng-if, still doesn't work.

yleigh avatar Dec 12 '14 17:12 yleigh

Take a look at this plunker: http://plnkr.co/edit/b0Ro3jAkTyzqQGXeAgvt?p=preview

If you change the value of $scope.editable to true the id column is editable, if you leave it false then the id column is not editable. I suspect you have some sort of syntax error in your code that is causing your parse error.

PaulL1 avatar Dec 12 '14 18:12 PaulL1

OK. if I do it like your example, it works. I suspect that if I use cellEditableCondition: "row.entity.isGroup" it somehow didsn't see this value when it's setting editable? $scope.gridOptions.columnDefs = [ { name:'name', enableSorting: false, cellEditableCondition: "row.entity.isGroup", cellTemplate: '

{{row.entity.isGroup}} {{row.entity.name}}
'}, ]

yleigh avatar Dec 12 '14 19:12 yleigh

I changed ur plunker above to like this, $scope.gridOptions.columnDefs = [ { name: 'id', cellEditableCondition: "row.entity.isActive", width: '10%' }, ... But then all cells in the first column are editable.

Maybe I shouldn't use it like that way?

yleigh avatar Dec 12 '14 19:12 yleigh

All right, I figured it out, it should be like this: cellEditableCondition: function($scope){return $scope.row.entity.isGroup},

yleigh avatar Dec 12 '14 20:12 yleigh