Like this: updated with change handler
var app = angular.module('myApp', ['ngGrid']);
app.controller('MyCtrl', function($scope) {
$scope.myData = [{
name: "Moroni",
age: 50,
dude: true
}, {
name: "Tiancum",
age: 43,
dude: true
}, {
name: "Jacob",
age: 27,
dude: false
}, {
name: "Nephi",
age: 29,
dude: true
}, {
name: "Enos",
age: 34,
dude: false
}];
$scope.gridOptions = {
data: 'myData',
columnDefs: [{
field: 'name',
displayName: 'Name'
}, {
field: 'age',
displayName: 'Age'
}, {
field: 'dude',
displayName: 'Dude',
cellTemplate: '<input type="checkbox" ng-model="row.entity.dude" ng-click="toggle(row.entity.name,row.entity.dude)">'
}]
};
$scope.toggle = function(name, value) {
//do something usefull here, you have the name and the new value of dude. Write it to a db or else.
alert(name + ':' + value);
}
});
You now can add an change handler or just set the input to disable/readonly if you just want to display the value.
(I'm so sorry for Jacob and Enos!)