[BUG] on_change events of DataTable CDS fail when source is set after init
See original GitHub issueSoftware version info bokeh 2.0.0 chrome 80.0.3987.132 (Official Build) (64-bit) ubuntu 19.10
Description of expected behavior and the observed behavior Context:
- An on_change(‘data’, callback) is registered on the ColumnDataSource which is attached to a DataTable
- An on_change(‘indices’, callback) is registered on the “selected” field of a ColumnDataSource which is attached to a DataTable
Expect:
- The callback will be called while the content in the DataTable is edited
- The callback will be called while a row in the DataTable is selected
Observed:
- Both callbacks are not called
Complete, minimal, self-contained example code that reproduces the issue
from bokeh.io import curdoc
from bokeh.models import TableColumn, ColumnDataSource, DataTable
columns = [TableColumn(field='a', title='a'),
TableColumn(field='b', title='b'),
TableColumn(field='c', title='c')]
cds = ColumnDataSource(dict(a=[1,2,3],b=[2,3,4], c=[3,4,5]))
table = DataTable(editable=True, width=300, height=150)
table.source = cds
table.columns = columns
def on_data(attr, old, new):
print('on_data')
def on_select(attr, old, new):
print('on_select')
table.source.on_change('data', on_data)
table.source.selected.on_change('indices', on_select)
curdoc().add_root(table)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Reload/refresh table after event — DataTables forums
I am trying to reload the table but I can't seem to find the way to call the reload function. In the .done...
Read more >How to reinitialize dataTables with newly fetched data from ...
You're re-initializing the table with different options in fetchNews() . You need to destroy the table first, see http://datatables.net/manual/ ...
Read more >jQuery DataTables: Why click event handler does not work
Provides solution to a problem when click and other event handlers don't work on pages other than first or when table is sorted...
Read more >Uncaught TypeError: Cannot read property of undefined
If you get undefined error, you need to make sure that which ever variables throws undefined error, is assigned a value to it....
Read more >Combo box OnChange - Power Platform Community - Microsoft
The population of the combo is fine but the onchange event does not work with more than on set of choices. Please see...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@maeglin89273 your code works for me if I change to pass
source
directly toDataTable
:It should work the way you have it too, and I am not sure why it does not, but hopefully this is an immediate solution for you.
@mattpap for reference this solves the issue:
Would you be in favor of this approach to get rid of initializers on models more generally?