0

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.

karel
  • 5,489
  • 46
  • 45
  • 50
Yatharth Mishra
  • 107
  • 1
  • 3
  • 17

1 Answers1

1

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']);
    }
  }
Ghonima
  • 2,978
  • 2
  • 14
  • 23
  • using ag grid version 18.0 – Yatharth Mishra Mar 01 '19 at 06:19
  • If you're using both events, the onCellValueChanged would set it when a field is edited and then you can use it in the onRowValueChanged – Ghonima Mar 01 '19 at 09:57
  • Thanks very much for answering and explaining the logic ,This is exactly what I was looking for. – Yatharth Mishra Mar 01 '19 at 10:40
  • Actually I am using a drop-down list with fixed values for a column ,so on clicking on a row for editing the row having that column(initially the value is null) , the drop-down list value is also initialized to the first option in the dropdown for the row ,so because of that the changed columns also contain that column name. But I am not editing any thing – Yatharth Mishra Mar 06 '19 at 08:45