Black Lives Matter. Please consider donating to Black Girls Code today.

Putting Variable Names in Style Data Conditional in Dash DataTable

dash_table.DataTable(
                                                id='warehouse_datatable',
                                                editable = False,
                                                sorting=True,
                                                filtering =True,
                                                sorting_type="multi",
                                                row_selectable="multi",
                                                style_table={'overflowX': 'scroll'},
                                                columns=[{"name": i, "id": i} for i in warehouse_rates_df.columns],
                                                data = warehouse_rates_df.to_dict("rows"),
                                                style_data_conditional = [ 
                                                                             { 'if' : {'column_id' : 'ReceiveRate', 'filter': 'ReceiveRate 
> num(10)' } , 'backgroundColor' : '#CCFFCC', 'color' : 'black'},
                                                                         { 'if' : {'column_id' : 'ReceiveRate', 'filter': 'ReceiveRate > 
num(8)' } , 'backgroundColor' : '#E5FFCC', 'color' : 'black'}

instead of putting num(10), is there a way of putting a input value from the user? Because the ‘num(10)’ is wrapped in strings, is it even possible?

same question here. Tried to pass a variable to style_data_ conditional, it doesn’t seem to work.

Can anyone share a working example of passing a variable to style_data_conditional? such as if {val} < given_variable

Started using dash a few weeks ago so I might be late with an answer. Here is what I did:

dict_if = {‘column_id’: ‘Efficiency’, ‘filter_query’: '{Efficiency} eq ’ + str(max_eff)} # dictionary to fit the if condition
style_data_conditional=[
{
‘if’: dict_if,
‘backgroundColor’: ‘#3D9970
}