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

Datatable: “style_data_conditional” - several conditions

Hi,
So can I indicate in some way several conditions?
next code doesn’t work:

style_data_conditional=[
                    {
                        'if': {
                            'row_index': 3,
                            'column_id': i,
                            'filter_query': '{' + str(i) + '} > 100'
                        },
                        'backgroundColor': '#99EE6B'
                    } for i in col_list,
                   {
                       'if' : {
                           'row_index' : 3,
                           'column_id' : i,
                           'filter_query' : '{' + str(i) + '} < 100'
                       },
                       'backgroundColor' : '#FF7373'
                   } for i in col_list

                ]

@Masya

Try this:

style_data_conditional=[
    {
        'if': {
            'row_index': 3,
            'column_id': i,
            'filter_query': '{' + str(i) + '} > 100'
        },
        'backgroundColor': '#99EE6B'
    } for i in col_list
] + [
    {
        'if' : {
            'row_index' : 3,
            'column_id' : i,
            'filter_query' : '{' + str(i) + '} < 100'
            },
            'backgroundColor' : '#FF7373'
    } for i in col_list
]
1 Like

@dimark
Thank you very much for your help, it works, I spent a lot of time on this.