I searched a lot around this problem but didn't get any solution which is actually working out to fulfill my needs.
Problem: I wanted to select the row entity on clicking of the checkbox having a columnDef as [{name: 'field01', displayName: '', field: 'field01', cellTemplate: "<input type='checkbox' ng-model='row.entity.field01' ng-click='grid.appScope.myhello()' />"}
].
I am building this columnDef dynamically based on another JSON [Updating Working Code]
$scope.columnDef = function(){
var column = [{name: 'field01', displayName: '', field: 'field01', cellTemplate: "<input type='checkbox' ng-model='row.entity.field01' ng-click='grid.appScope.myhello(\"row.entity.field01\")' />"}], coltype = [];
angular.forEach($scope.columns, function(value, index){
coltype = [];
switch(value.type){
case "Number": coltype.push({type: "number"});
break;
case "String": break;
case "Boolean": coltype.push({editableCellTemplate: "ui-grid/dropdownEditor", cellFilter: "mapBool", editDropdownValueLabel: "bool", editDropdownOptionsArray: [{ id: 1, bool: 'Yes' },{ id: 2, bool: 'No' }] });
break;
case "Date": coltype.push({type: 'date', cellFilter: 'date:"MM/dd/yyyy"'});
break;
}
column.push(angular.extend({name: value.name, displayName: value.name, enableCellEdit: (value.edit.indexOf("No") != -1) ? false : true}, coltype[0]));
});
return column;
};
$scope.gridOptions.data = $scope.datagrid;
$scope.gridOptions.columnDefs = $scope.columnDef();
$scope.myhello = function(value){
console.log("It works!!! :-) " + value);
};
The above code updates the datagrid JSON of the field01 but it don't call the ng-click function. I referenced two Plunkr one with external-scope in ui-grid Plunkr and another one with defining a method in gridoptions and call it locally Plunkr (In this plunker the ng-click is getting called but when I tried checking the value inside the editUser function it was not working as expected).