I am using angularjs and ui.grid. I've some problem. I want checkbox auto checked after I edit cell.. I've Tried So Many Times to code auto checked after edit cell but still not success. How the best way to solve it.
this my demo in plnkr
Example code
$scope.checkboxData = false;
$scope.checkboxCheck = checkboxCheck;
function checkboxCheck(params, statusCheck) {
console.log("test checked");
console.log(params);
console.log(statusCheck);
}
$scope.gridOptions = {
enableCellEdit: false,
enableCellEditOnFocus: true,
cellEditableCondition: function($scope) {
return $scope.row.entity.isActive;
}
};
$scope.gridOptions.columnDefs = [
{name: 'isActive', displayName: 'Edit Status', enableColumnMenu: false, cellTemplate: 'cellTemplate_lock.html'}, // displays isActive status as a button and allow toggling it
{name: 'name', enableCellEdit: true}, // editing is enabled for this column, but will be overridden per row by cellEditableCondition
{name: 'company', enableCellEdit: true},
{ displayName: 'Select', name: 'checkbox', field: 'checkboxData', enableFiltering: false, enableCellEdit: false, cellTemplate: '<span style="margin-left: 0px;"><input class="Checkbox" type="checkbox" name="checkboxData" ng-model="checkboxData" ng-click="grid.appScope.checkboxCheck(row.entity, checkboxData)" id="{{row.entity.seq_no}}"></input><label for="{{row.entity.seq_no}}"><span></span></label></span>',width: 60 } // same for this column
];
$scope.gridOptions.onRegisterApi = function(gridApi) {
$scope.gridApi = gridApi;
gridApi.edit.on.afterCellEdit($scope, function(rowEntity, colDef, newValue, oldValue) {
$scope.msg.lastCellEdited = 'ID: ' + rowEntity.id + ', Column: ' + colDef.name + ', New Value: ' + newValue + ', Old Value: ' + oldValue;
$scope.$apply();
});

Maybe you need to add this : rowEntity.checkboxData = true;