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

Updating a Dash Table column order

I am trying to use the dash_table_experiments import to display an interactive table. Up till now it has been working exactly as I have wanted it to.

However I want to allow user to change the order in which columns are displayed. However the column order will not update despite the fact it gets passed a DataFrame with the input in a different order (which I can see by printing the DataFrame it gets passed). The interior of cells will update correctly but the order will remain static, until another column is added at which point the columns update.

I was hoping someone who has the knowledge could confirm that this is expected behaviour and that I’m not losing my mind.

I am not sure why the order is not changing. Are you using something similar to the code below? I think it should change according to dataframes.columns.

import dash_table_experiments as dt
html.Div(dt.DataTable(
        rows=[{}],
        columns=dataframes.columns,
        ...
        ))

Thanks for the reply.

I think the issue is the callback with “rows” expects a dictionary. Because the dictionary doesn’t preserve order.