angularjs - How to pass row.entity inside celleditablecondition in UI-grid? -
i trying set celleditablecondition
based on content of other cell in same row.
for how pass row.entity celleditablecondition?
i tried passing row arguement function defined oncelleditablecondition row object not have entity property.
i want below:
columndefs: [{ name: 'column1', field: 'name', celleditablecondition: function(row) { return row.entity.lastname === 'adams' } }, { name: 'column2', field: 'lastname' }]
this small tweak code should it:
var app = angular.module('app', ['ui.grid', 'ui.grid.edit']); app.controller('mainctrl', ['$scope', function($scope) { $scope.gridoptions = { columndefs: [{ name: 'column1', field: 'name', celleditablecondition: function(scope) { return scope.row.entity.lastname === 'adams' } }, { name: 'column2', field: 'lastname' }], data: [{name: "tim", lastname: "harker"}, {name: "akash", lastname: "adams"}] } }]);
div[ui-grid] { height: 130px; }
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-grid/4.0.2/ui-grid.min.js"></script> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/angular-ui-grid/4.0.2/ui-grid.min.css" /> <div ng-app="app" ng-controller="mainctrl"> <div ui-grid="gridoptions" ui-grid-edit> </div> </div>
let me know if have other questions. happy further, if needed.
Comments
Post a Comment