Get the edited columns (with data) if performing a full row update using ag-Grid with Angular 6

2.1k Views Asked by At

I have already implemented full row update, but before updating the rows I need to get which columns have been edited and the respective data present in the columns. In order to perform some validations on the data for displaying an error message before updating the row, I am using (rowValueChanged)="onRowValueChanged($event)" method.

1

There are 1 best solutions below

4
On BEST ANSWER

I believe to accomplish this, you would need to listen on both the rowValueChanged, cellValueChanged events and add a flag with the edited value

  onRowValueChanged(event) {
    console.log(`Changed Values = ${event.node.changedValues.join(',')}`);
    // do validations
  }

  onCellValueChanged(event) {
    if (event.newValue !== event.oldValue) {

      if (!event.node.changedValues)
      event.node.changedValues = [];

      event.node.changedValues.push(event['column']['colId']);
    }
  }