I am looking for dynamic rendering of cells in ag-grid based on a settable threshold value above which the cell is rendered green else red.
I tried the following:
<AgGridReact
onGridReady={onGridReady}
pagination={true}
columnDefs={[
{ headerName: "SYMBOL", field: "symbol" },
{
headerName: "PRICE",
field: "price",
volatile: true,
cellStyle: function (params) {
if (params.value < threshold) {
return { backgroundColor: "red" };
} else {
return { backgroundColor: "green" };
}
}
}
]}
/>
and take input for threshold (which sets the state). However, even though the state changes no change happen in the columnDefs
.
I am using .applyTransactionAsync()
for high frequency updates. Hence upon using .setColumnDefs()
the table does not show any data.
Is there any way that this cell styling happens based on a dynamic condition on dynamic data instead of a fixed one?