0

I am trying to cancel a change of value after editing a cell. The flow is :

  • finish edition ( onCellValueChanged )
  • request to web service:
  • if request fail cancel edition ( reverse to old value ).
  • if request is ok nothing to do

Fot that I try to use the gridOptions.onCellValueChanged listener, which works but the event.newValue is the same as event.oldValue:

this.gridOptions.onCellValueChanged = event => {
         // Here event.newValue == event.oldValue
      }

The cell model is an object (not a string or a simple type ). So I tracked down the problem to maybe the redefinition of equals within the coldef :

coldef: {
 /* a lot of def ...*/
 equals: function(object1, object2) {
        console.log("equal : ", object1, object2);
        return object1.Id === object2.Id;
       },
     };

But here ont the log object1 and object2 are undefined. Why is that ? And bonus question : is this the good way to cancel the change of cell data ?

sebius
  • 102
  • 2
  • 14
  • question already [answered](https://stackoverflow.com/questions/55358430/how-to-implement-validation-rules-for-ag-grid-row-edit/55362090#55362090) few times – un.spike Apr 10 '19 at 05:36
  • @un.spike thanks but still not what i am looking for ... but it made me think of the flow ... Indeed my issue is that I validate editing and then whithin the valuechanged event I do a check with web service, to be able to cancel that change at the end of this event. – sebius Apr 10 '19 at 08:12

1 Answers1

0

you need to add a valueGetter function in colDef, equals function gets its params from valueGetter function

Amresh Kumar
  • 158
  • 2
  • 8