I have a table that loads from dynamically changing data. It refreshes every 5 secs. I'm using ag-grid for it using this example: https://www.ag-grid.com/javascript-grid-sorting/index.php
Is it possible to change color of the cells whose values have changes, like suppose a cell value is 100 and it becomes (less than this i.e. <100) so make the cell red color, id it becomes greater, make it green color. I'm trying to do it using this example: https://www.ag-grid.com/javascript-grid-cell-styling/index.php
But I can't understand how to do this.
UPDATE: I'm doing it this way, but it's not changing the color:
var columnDefs = [
{headerName: "Arr Px Slippage", field: "total_wt_arr_slp", width: 100, newValueHandler: compareValues},
{headerName: "IVWAP Slippage", field: "total_wt_ivwap_slp", width: 100}
];
function compareValues(params) {
if (params.oldValue > params.newValue){
return {color: 'green', backgroundColor: 'black'};
console.log(params.newValue);
}
if (params.oldValue < params.newValue){
return {color: 'red', backgroundColor: 'black'};
}
}