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

Change currently selected row in Dash datatable with callback

In a Dash datatable, when row_selectable is set to single, there are radio buttons that can be clicked by the user to the left of the table. Is it possible to reselect these radio buttons programmatically with a callback (for example, a next button that indexes the user through the rows)?

I was hoping to do something like this:

@app.callback(
    Output('table', 'selected_row_ids'),
    [Input('next-button', 'n_clicks'),
     State('table', 'selected_row_ids')]
)
def index_next_row(n_clicks, selected_rows):
    index = selected_rows[0]
    return [index + 1]

Nevermind, selected_rows works when row_selectable is set to single, but not selected_row_ids.

1 Like