I am trying to use conditional formatting to update a table’s style for rows where certain columns have a certain value. I looked at the docs here and I also looked at this question. However when I have configured my app it still doesn’t highlight.
My callback looks like so:
@app.callback(
Output("scope-0-table", "data"),
Output("scope-0-table", "style_data_conditional"),
Input("button", "n_clicks"),
State("bp", "value"),
prevent_initial_call=True,
)
def populate_tables(n_clicks, bp):
try:
# logic to create df_ret_zero
return (
df_ret_zero.to_dict("records"),
[{
'if': {
'filter_query': '{{my_col}} = {}'.format(bp),
},
'backgroundColor': '#FF4136',
'color': 'white'
}],
)
except Exception as e:
print("error style")
print(str(e))
raise PreventUpdate
My understanding is that this should work. It should select every row that has my_col
value equal to bp
. Am I missing something here?