Dash DataTable active_cell missing row_id

Title says it all, I’m trying to set up a callback to the selected cell by user, using:

@app.callback(Output('log', 'children'),
              Input('my-sortable-table', 'active_cell'),
              State('my-sortable-table', 'data'))
def print_active_cell(active_cell, data):
        return str(active_cell)

Outputs to console:
{'row': 4, 'column': 1, 'column_id': 'limit'} .

The active_cell dictionary is missing row_id.

Anything I should do to make sure this property gets passed on?

As I want the table to be sortable, the value passed in row is no good.


Hi @patricio.panichelli

In order for the row_id to be included in the active_cell dict, the id must be available in the data rows.

Before you sort or filter your df, you can create a row id like this:

df['id'] = df.index

See more information in the section called “Row IDs” here

Thanks! Surely this solves the issue. I must have skipped that caveat in the documentation. I’ll give it a try and get back in case of any problems.

1 Like