Open fpriebe opened 4 years ago
First thought was for a simple change where the table internally checks whether newData == oldData
and triggers a data_previous
update based on that. But I don't think this can work, because:
@app.callback(
Output('table', 'data'),
[Input('table', 'data_previous')],
[State('table', 'data')]
)
def some_callback(previous, current):
# do something
Forcing the table to update data_previous
when data
is updated would cause an infinite loop for the callback defined above.
Some user action caused data --> data*
and data_previous=data
The callback does (data, data*) --> data**
The table checks data** != data*
and assigns data_previous=data*
The callback is triggered again, potentially ad finitum.
For the scenario above, it should be possible to combine both callbacks into a single callback that updates data
and uses the baseline and new value to update the divs at the same time. This will also have the added advantage of avoiding a 2nd roundtrip with data and data_previous.
In light of this, it might be necessary to define data_previous
as the previous value of data, when data was updated by the table itself.
I recently discovered that my change management for an editable DataTable did not work as expected. The problem is that the 'data_previous' value of the DataTable is not modified if you change the data of the table with a callback.
The reference states that the 'data_previous' value is updated both ways: by user changes using the editable function and by callbacks manipulating the table data.
Here is a minimal example, which shows the bug: I discovered the bug in dash 1.4.0 and dash-table 4.4.0, but it is also present in the latest versions of dash and dash-table.