0
votes

I have searched for a long time for this and I'm sure I must have missed something because it is such a basic ask.

I define the formats in my grid through the cellClass field in defaultColDef:

cellClass: (params) => {
    if (params.data.signal_days === 1 && params.data.trade_type !== "taken"  ) {
        return "signals-blotter-cell-new";
    } else if (params.data.trade_type === "taken"  ) {
        return "signals-blotter-cell-taken";
    }
}

Depending on the value of the signal_days and trade_type columns, different css classes get applied.

I also have a onCellValueChanged event listener defined as such :

onCellValueChanged: (event) => {
    if (event.column.colId === "trade_type") {
    }
}

How can I refresh the cells for the whole row where the modification happened so that my css classes are properly applied ? I would need to refresh when the value of the trade_type column changes from anything to "taken". Some other question use that same mechanism for a single cell which does not help me in that case.

1
It doesn't because it doesn't change the style on the row. only on the specific cell (which I already do with my existing code) I need the refresh to happen on the whole row. - Chapo
well the idea is the same, you need to call params.api.refreshCells() and pass the rowNode you want to refresh - Pratik Bhat
Yes I do not know how to get the rowNode from the event object - Chapo
and the refresh needs to happen within onCellValueChanged : do I have access to params there ? Thought event was the only object available. - Chapo

1 Answers

1
votes

You could do something like -

onCellValueChanged: (event) => {
    if (event.column.colId === "trade_type") {
       event.api.refreshCells({
                    force: true,
                    rowNodes: [event.node] // pass rowNode that was edited
            });
    }
}