plotly / dash-table-experiments

NO LONGER SUPPORTED - use https://github.com/plotly/dash-table instead
MIT License
174 stars 57 forks source link

sort/selected rows reset while using PreventUpdate exception on callback #73

Open rquintino opened 6 years ago

rquintino commented 6 years ago

When using table and PreventUpdate exception on a callback, although the table data is not changed as expected by raising PreventUpdate , table sort/selected indexes seem to reset.

Checked the periodic http call for the interval component, seem to return expected 204/no content response, but still triggering table filter/sort/selections

related threads: https://github.com/plotly/dash/pull/190 https://github.com/plotly/dash-table-experiments/issues/64

http response: HTTP/1.0 204 NO CONTENT Content-Type: text/html; charset=utf-8 Content-Length: 0 Server: Werkzeug/0.14.1 Python/3.6.3 Date: Mon, 11 Jun 2018 08:52:27 GMT

http request: {"output":{"id":"datatable-simple","property":"rows"},"inputs":[{"id":"my-interval","property":"n_intervals","value":538}]}

app import datetime import sys import pandas as pd

app = dash.Dash()

DF_SIMPLE = pd.DataFrame({ 'x': ['A', 'B', 'C', 'D', 'E', 'F'], 'y': [4, 3, 1, 2, 3, 6], 'z': ['a', 'b', 'c', 'a', 'b', 'c'] })

app.layout = html.Div([ html.H4('DataTable Sample',id="app_title"), dt.DataTable( rows=DF_SIMPLE.to_dict('records'),id='datatable-simple' ), dcc.Interval(id='my-interval', interval=5000), ], className="container")

app.css.append_css({ 'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css' })

@app.callback( Output('datatable-simple', 'rows'), [Input('my-interval', 'n_intervals')]) def update_table(n): print("Checking...") raise dash.exceptions.PreventUpdate("No data changed!")