Hi,
I have a DataTable with editable cells and I want to do something with the old and new data when a cell is edited.
The problem is that both old and new parameters of my callback function have the same value (the new values), so I can’t track the changes between edits.
Is this expected? Am I missing something? Do you have any idea how can I get the old values (or the difference between edits)?
My code:
from bokeh.models import ColumnDataSource, DataTable, TableColumn, StringEditor
from bokeh.plotting import figure, curdoc
from bokeh.layouts import column
def cluster_name_changed(attr, old, new):
print(old)
print(new)
cluster_field = ‘CLUSTER’
table_clusters_source = ColumnDataSource(data=dict(cluster_no=[1, 2, 3]))
columns_clusters = [TableColumn(field=‘cluster_no’,
title=“Cluster Name”,
editor=StringEditor())]
table_clusters = DataTable(source=table_clusters_source,
columns=columns_clusters,
width=300,
height=200,
editable=True)
table_clusters_source.on_change(‘data’, cluster_name_changed)
curdoc().add_root(column(table_clusters))
``
and the console output when I update the third cell from “3” to “third”:
{‘cluster_no’: [1, 2, ‘third’]}
{‘cluster_no’: [1, 2, ‘third’]}
I also [asked this question on StackOverflow](https://stackoverflow.com/questions/54987555/bokeh-old-and-new-parameters-for-on-change-event-of-a-columndatasource-have-the) so you can find a bit more information there.
This was tested with Bokeh versions 1.0.1 and 1.0.4.
Thank you for your help,
Madalin