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

Update DataTable active_cell via callback

Hi, how do I update the DataTable active_cell?

Say I have an input value. I want my DataTable to highlight the row with the id identical to the input value. I can’t figure out how to update this.

Hello @aochtman,

Thanks for using Dash! I hope this will help you out.

You should be able to update the active_cell as long as the callback value is provided the proper dict syntax with the right keys (row, column, row_id, column_id).

Now, highlighting a row will entail something different than changing the active cell. The documentation on this feature is under “Conditional Formatting - Highlighting Certain Rows” in the Styling the DataTable chapter.

Here is an example to illustrate both — I couldn’t get paginated row indices to work for now, but you should get the idea. I’m also not a Pandas expert :sweat_smile:. Hopefully, you can see a live demo here.

In this demo, I’m modifying the “Dash Table & Interactivity” example in the Dash Docs.

Hello @wbrgss,

There seems to be a bug with changing active_cell prop in a callback.
As seen in the picture below, the new active_cell gets the red border around it to show that it is selected. However the old active_cell (before the callback) still gets highlighted with a red background. It doesnt seem to carry over.



I would argue this is not a bug. There is a distinction between “active” and “selected” cells that is reflected in the separate prop selected_cells. Maybe this issue description will help clear up the distinction: I forked my demo app to reflect the behavior you want, using selected_cells as an additional output in the callback (demo here):

1 Like

Hi @wbrgss ,

Thank you for the explanation! The second problem I faced was similar to @dimark but you have given an explanation for this as well. Thanks for the help, I am good now :slight_smile: