Hi
I’m having trouble updating source data when using Bokeh server and a customJS. Using the code below as an example, when I change the spinner value new rows are added to the table. Clicking the green button (after adding some new rows) should print the updated source data to the console, however it only prints {‘x’: [99]} which is the original source data. Any idea why the source data on the server side is not being updated with the source.change.emit() code?
I’m using the latest version of bokeh.
Thanks in advance
Matt
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource, CustomJS, DataTable, TableColumn
from bokeh.models import Spinner, Button, Row
from bokeh.events import ButtonClick
source = ColumnDataSource({'x': [99]})
spinner = Spinner(low=0, high=10, step=1, value=5, width=100)
button = Button(label="print table to console", button_type="success", width=200)
columns = [TableColumn(field="x", title="x")]
table = DataTable(source=source, columns=columns, width=100)
callback_spinner = CustomJS(args=dict(source=source), code="""
source.data['x'].push(cb_obj.value);
source.change.emit();
""")
spinner.js_on_change('value', callback_spinner)
def callback_button(event):
print(table.source.data)
button.on_event(ButtonClick, callback_button)
curdoc().add_root(Row(spinner, table, button))