Dash 2.0 DataTable Previous Data Loses Column Order
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
In dash v1.19.0 with dash-table v4.11.2 the data_previous property of a DataTable retained the order of the columns
In dash v2.0.0 this property now returns the columns ordered alphabetically; not based on previous ordering
Minimal reproducible example:
from dash import Dash, Input, Output, State
from dash.exceptions import PreventUpdate
from dash.html import Div, Button
from dash.dash_table import DataTable
from pandas import DataFrame
df = DataFrame(dict(Z=[1, 2, 3], A=[7, 8, 9], L=[4, 5, 6]))
app = Dash(__name__)
table = DataTable(id='table', columns=[dict(name=i, id=i, deletable=True) for i in df.columns],
data=df.to_dict('records'))
undo_button = Button(id='undo-button', children='Undo')
app.layout = Div([Div(table), Div(undo_button)])
@app.callback([Output(table.id, 'columns'), Output(table.id, 'data')],
Input(undo_button.id, 'n_clicks'),
State(table.id, 'data_previous'))
def undo(n_clicks, previous_data):
if n_clicks is None:
raise PreventUpdate
df = DataFrame(previous_data)
return [dict(name=i, id=i, deletable=True) for i in df.columns], df.to_dict('records')
if __name__ == '__main__':
app.run_server()
If I delete any of these columns, and then click the undo button, I expect the deleted column to be restored, and the order of the columns to remain Z, A, L
Initial table:

Deleted column:

Following undo:

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the minimal reproducible example with the stated Dash and dash-table versions, focusing on DataTable's data_previous property after deleting a column. Compare the returned record order between versions and verify that restoring the deleted column preserves the original Z, A, L order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100