0
votes

I am trying to style a cell with a particular background color if the 'oldValue' and 'newValue' are not equal in the 'onCellValueChanged' handler.

var gridOptions = {
    columnDefs: columnDefs,
    rowData: rowData,
    onCellValueChanged: function(params) {
      if(params.oldValue !== params.newValue) {
        params.colDef.cellStyle = function(params) {
        return { backgroundColor: 'green'}; 
      }
    }
  }
 };

When I am editing the cell value to a new value, I don't see the style change being applied on tabbing out or clicking any other cell. Rather, I have to click back on the edited cell again and click outside after that to see the style being applied. I am not sure what is happening, can someone guide me here. I am also adding the demo

1
Have a look at the API documentation for refreshCells(). That should enable to force the change to appear immediately. - S. Baggy
params.api.redrawRows() is forcing the change to appear immediately. - C.O.G
Working demo - C.O.G

1 Answers

0
votes

Bind it to your template

<ag-grid-angular  (cellValueChanged)="onCellValueChanged($event)">
</ag-grid-angular>