datable checkbox editor

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

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 [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/26a56af8-df11-42db-845d-3e73ce7b61c4%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

thanks Bryan,

Commenting back in the checkbox editor, your example works fine with Firefox and bokeh with several versions of both.

Not with Safari or Chrome where symptoms are the ones you describe.

I wish however a callback directly linked to a CheckboxEditor, so a double click would be enough to trigger the call.

In the current situation, we also need to unfocus the cell, so that it triggers the columndatasource callback as in your example.

Bottom line seems related to the fact that in general cell editors don’t listen to property changes.

···

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](http://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 [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/26a56af8-df11-42db-845d-3e73ce7b61c4%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

thanks Bryan,

Commenting back in the checkbox editor, your example works fine with Firefox and bokeh with several versions of both.
Not with Safari or Chrome where symptoms are the ones you describe.

Definitely seems like a bug, please file an issue on GitHub:

  Issues · bokeh/bokeh · GitHub

I wish however a callback directly linked to a CheckboxEditor, so a double click would be enough to trigger the call.
In the current situation, we also need to unfocus the cell, so that it triggers the columndatasource callback as in your example.

Bottom line seems related to the fact that in general cell editors don't listen to property changes.

I think finer grained notifications are not unreasonable, but do represent new development. Feel free to make a feature request issue on GitHub to discuss things. For the time being, the best option is to make a custom extension of some sort.

Thanks,

Bryan

···

On Mar 12, 2017, at 04:55, chupach <[email protected]> wrote:

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\.

Hello Bryan,

this issue is already filled in GitHub. It was recently discussed and still open:

···

CheckboxEditor in DataTable does not display value without focus #2903

thx.

On Sunday, March 12, 2017 at 9:31:34 PM UTC+1, Bryan Van de ven wrote:

On Mar 12, 2017, at 04:55, chupach [email protected] wrote:

thanks Bryan,

Commenting back in the checkbox editor, your example works fine with Firefox and bokeh with several versions of both.
Not with Safari or Chrome where symptoms are the ones you describe.

Definitely seems like a bug, please file an issue on GitHub:

    [https://github.com/bokeh/bokeh/issues](https://github.com/bokeh/bokeh/issues)

I wish however a callback directly linked to a CheckboxEditor, so a double click would be enough to trigger the call.
In the current situation, we also need to unfocus the cell, so that it triggers the columndatasource callback as in your example.

Bottom line seems related to the fact that in general cell editors don’t listen to property changes.

I think finer grained notifications are not unreasonable, but do represent new development. Feel free to make a feature request issue on GitHub to discuss things. For the time being, the best option is to make a custom extension of some sort.

Thanks,

Bryan

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](http://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 [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/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.