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

Filtering rows in dash table

Hi everyone, I am preparing a dash where I have to put filters in columns. this is my code. The filter is coming in the table but the table is not getting filtered. Kinldy help.

                                                  columns=[{'id': c, 'name':c, "deletable": True} for c in columns],
                                                  n_fixed_rows = 1,
                                                  style_cell={'width': '150px', 'textAlign': 'center'},
                                                  style_table={'overflowX': 'auto','overflowY':'auto','maxHeight': '400px','minwidth':'100%','font-family':'Calibri'},
                                                            'backgroundColor':  'rgb(52,98,145)',
            #                                                    'fontWeight': 'bold',
                                                  ), html.Div(id='datatable-filter-container'),

Unlike the example shown here-

I am not putting the datatable in app layout but in the function below callback. There are multiple html.Div in the function. How will this callback get to know which html.Div to call ?

    Output('datatable-filter-container', "children"),
    [Input('datatable-filtering-fe', "data")])
def update_graph(rows):
    if rows is None:
        dff = df
        dff = pd.DataFrame(rows)

Hi @ajeeteshmishra, the callback in the example you’re mentioning is not doing anything, it’s just to show that you can listen to filtering events and trigger callbacks. You do need to define the datatable in the layout of your app though. I would just remove the callback and define the table in the layout.

1 Like

Thank you @Emmanuelle