getRowStyle not setting background color

Based on the example here:

I’m trying to conditionally set the background of my rows based on a column value.

I wrote a loop like this to build the getRowStyle object:

getRowStyle = None
if conditionalRowColumnName is not None:

    backgroundColors = [ '#EAF2F8', '#E8F8F5', '#FEF9E7', '#FDF2E9', '#F8F9F9', '#E9F7EF', '#F4F6F6', '#EAECEE']
    # get unique values for column from table dfInput
    uniqueValues = dfInput[conditionalRowColumnName].unique()
    getRowStyle = {
        "styleConditions": [
        ],
        "defaultStyle": {"backgroundColor": "grey", "color": "white"},
    }
    counter = 0
    for value in uniqueValues:
        getRowStyle['styleConditions'].append({
            "condition": f"params.data.{conditionalRowColumnName} == '{value}'",
            "style": {"backgroundColor": f"{backgroundColors[counter]}"},
        })
        counter += 1

This worked for a while, and now this morning, I notice that it is no longer setting the background colors. The rows are always white.

I’m using dash-ag-grid 2.3.0

I’m wondering if something changed this week(?)

Hello @zack_nc,

Nothing should have changed, especially since you didnt update to 2.4. :stuck_out_tongue:

I’d print your getRowStyle and start debugging there.

Thanks,

Do you see anything in my getRowStyle that looks wrong?

I want to color the rows based on the Rank column.

(also just updated to 2.4.0 :slight_smile:

Make sure that the column capitalization matches in the data.

Also, all the other things are case sensitive, if you want the case not to matter, I’d recommend doing:

params.data.Rank.toLowerCase() == '3 - normal'