On Saturday, March 11, 2017 at 7:13:30 PM UTC+1, Bryan Van de ven wrote:
Hi,
The data table is just a view on a column data source. When you edit the table, what actually changes is the underlying table, so you actually want to put a callback on the data source:
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource, CustomJS
from bokeh.models.widgets import DataTable, TableColumn, CheckboxEditor
source = ColumnDataSource(dict(index=[10], x=[False]))
ed = CheckboxEditor()
data_table = DataTable(source=source, width=200, height=280, columns=[
TableColumn(field="x", title="x") #, editor=ed)
], editable=True)
def cb(attr,old,new):
print(attr,old,new)
cb_js = CustomJS(code='console.log("click")')
source.js_on_change('change', cb_js)
source.on_change('data', cb)
curdoc().add_root(data_table)
However, note that I have commented out the checkbox editor... it does not seem to be working reliably for me (after double clicking to edit, the checkbox is displaced and unresponsive). Is it working as expected for you? If so, what version? Perhaps there is some regression to fix.
Thanks,
Bryan
> On Mar 6, 2017, at 12:27, chupach <[email protected]> wrote:
>
> hi
>
> how do we get a callback called (python or js) when checkbox in the datatable is switched (before unfocusing the column, which can then easily be detected on columndatasource change) ?
> I tried a call to customjs, never called and python callback, but no attribute to detect a change.
>
> from bokeh.io import curdoc
> from bokeh.models import ColumnDataSource, CustomJS
> from bokeh.models.widgets import DataTable, TableColumn, CheckboxEditor
>
> source = ColumnDataSource(dict(index=[10], x=[False]))
>
> def cb(attr,old,new):print(attr,old,new)
> #def cb_cb(attr):print('click')
> cb_cb = CustomJS(code='console.log("click")')
> ed = CheckboxEditor()
> ed.js_on_change('change', cb_cb)
> # ed.on_change('change', cb_cb) # ??? which attr ?
> data_table = DataTable(source=source, width=200, height=280, columns=[
> TableColumn(field="x", title="x", editor=ed)
> ], editable=True)
>
> curdoc().add_root(data_table)
>
> thx
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/26a56af8-df11-42db-845d-3e73ce7b61c4%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/51e5c0df-433e-4cc7-a658-cce5d65cd781%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.