Anyone know how to detect the change in cell data in ng-grid. I want to
call save only if the cell data is changed. Now it calls save whenever
focus is out from the cell but I need to call it only when cell data is
chenged in the grid cell. My code looks like this:
*directive*
angular.module('app', [])
.directive('ngBlur', function () {
return function (scope, elem, attrs) {
elem.bind('blur', function () {
scope.$apply(attrs.ngBlur);
});
};
});
*ng-grid controller*
var cellEditableTemplate = "<input ng-class=\"'colt' + col.index\"
ng-input=\"COL_FIELD\" ng-model=\"COL_FIELD\" ng-blur=\"updateEntity(col,
row, row.getProperty(col.field))\"/>"
//get data
.....
.....
//display data
$scope.gridOptions = {
data: 'agencies',
enablePaging: true,
showFooter: true,
enableCellSelection: true,
pagingOptions: $scope.pagingOptions,
enableCellEditOnFocus: true,
multiSelect: false,
totalServerItems: 'totalItems',
columnDefs: [{ field: 'properties.description', displayName:
'Name', enableCellEdit: true, editableCellTemplate: cellEditableTemplate },
{ field: 'properties.phone1', displayName: 'Phone',
enableCellEdit: true, editableCellTemplate: cellEditableTemplate },
{ field: 'More Info', DisplayName: 'More Info',
enableCellEdit: false, cellTemplate: moreInfoCellTemplate }]
};
$scope.updateEntity = function (col, row, cellVal) {
window.alert("(Agency ID: " + row.entity.id + ") " +
col.displayName + " = " + cellVal + " is saved");
};
Thank you.
--
Tek Raj Bhatta
Toledo,OH
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.