0

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!

  • Have you checked this SO post? http://stackoverflow.com/questions/15647981/angularjs-and-ng-grid-auto-save-data-to-the-server-after-a-cell-was-changed – ForgetfulFellow Jul 17 '14 at 16:55
  • Yes and your comment on that helped. Am I correct in understanding that I use both start and end to detect changes? – honorableruler Jul 22 '14 at 14:24

1 Answers1

1

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.

Goodzilla
  • 1,483
  • 11
  • 17