0
votes

I have an editable ng-grid in my web application. The grid functions make my life easy and are truly great but I've noticed one minor problem that I don't know how to work around gracefully.

Namely, I want to detect when a user has made changes to the grid. Right now, I use...

$scope.$on('ngGridEventEndCellEdit', function(evt) {

  //function goes here!

});

...this works, kind of.

The problem is this event is triggered even when the user has NOT made a change to the cell but has only clicked/tabbed into/out-of it. I don't want to have to compare each field in the row from the before and after to detect if a change has been made -- is there a better way?

Thanks!

1
Yes and your comment on that helped. Am I correct in understanding that I use both start and end to detect changes? - honorableruler

1 Answers

1
votes

If you just want to detect when the user starts editing a cell :

$scope.$on('ngGridEventStartCellEdit', function(evt) {

  //function goes here!

});

(note the Start instead of End)

More details here

Otherwise, ForgetfulFellow's link should have your solution :

cellEditableTemplate = "<input ng-class=\"'colt' + col.index\" ng-input=\"COL_FIELD\" ng-model=\"COL_FIELD\" ng-change=\"updateEntity(row.entity)\"/>"

The ng-change will be called on each keystroke.