Search code examples
ag-gridag-grid-react

Updating cell value from callback in ag grid


I need to update the value of one of the cells in a row in ag-grid as soon as the onCellEditingStopped callback is called (this happens when a user exits any other cell on that row).

I have this code which is based on the single cell update example at Ag grid single cell update

onCellEditingStopped: {function(event) {
 event.node.setDataValue("cell_to_update","a new value");
}
}

which should update the cell with field "cell_to_update" but it doesnt.

I am wondering if that is because I am calling it from this specific callback?


Solution

  • One way is by forcing the refresh, like

    onCellEditingStopped: {function(event) {
     event.node.setDataValue("cell_to_update","a new value");
    event.api.refreshCells({force:true});
    }
    }