Help with AGGrid conditional column/cell color

I’m working on converting a table to an AGGrid.

So far, the grid is awesome - it’s MUCH more responsive and I like the code conventions.

However, I’m stuck trying to get conditional formatting to work.

My intention is that for each cell in certain columns, the value should be red in color if negative.

Based on the documentation, I’m trying this approach:

for i in table.columns:
entry = {‘headerName’: i, ‘field’: i}
entry[‘minWidth’] = 120


    if '24Hour' in i:
        entry['minWidth'] = 160
        entry['cellStyle'] = {
            "backgroundColor": "#F0FFFF",
            "styleConditions": [
                    "condition": "params.value < 0", "style": {"color": "red"}
                    "condition": "params.value > 0", "style": {"color": "black"}

I’ve also tried putting the same type of logic in the defaultColDef property.

in both cases, the table renders fine with no errors, but all values are black, including negative values.

Can someone tell me how to accomplish my goal here?

FWIW, I’m using version 2.0.0a1

Hello @zack_nc,

Welcome to the community!

You should try using 2.3.0, that is the latest.


Was able to get that to work!

1 Like