javascript - Angular js Grid Validation -
i want add validation, such cells of grid, have age more 40, show in red color?
<html ng-app="myapp"> <head lang="en"> <meta charset="utf-8"> <title>getting started nggrid example</title> <link rel="stylesheet" type="text/css" href="ng-grid.css" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="jquery-1.8.2.js"></script> <script type="text/javascript" src="angular.js"></script> <script type="text/javascript" src="ng-grid-1.3.2.js"></script> <script type="text/javascript"> var app = angular.module('myapp', ['nggrid']); app.controller('myctrl', function($scope) { $scope.mydata = [{name: "moroni", age: 50}, {name: "tiancum", age: 43}, {name: "jacob", age: 27}, {name: "nephi", age: 29}, {name: "enos", age: 34}]; $scope.gridoptions = { data: 'mydata', enablecellselection: true }; }); </script> </head> <body ng-controller="myctrl"> <div class="gridstyle" ng-grid="gridoptions"></div> </body> </html> how can that? please me?
you can add cell template grid
$scope.gridoptions = { data: 'mydata', enablecellselection: true columndefs: [{celltemplate: '<div ng-class="{red: row.getproperty(col.field) > 40}"><div class="ngcelltext">{{row.getproperty(col.field)}}</div></div>'}] }; see template examples section of docs more.
Comments
Post a Comment