Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable selectable='checkbox' gives JavaScript error #8050

Closed
markusdr opened this issue Jul 4, 2018 · 1 comment
Closed

DataTable selectable='checkbox' gives JavaScript error #8050

markusdr opened this issue Jul 4, 2018 · 1 comment

Comments

@markusdr
Copy link

@markusdr markusdr commented Jul 4, 2018

ALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)

bokeh 0.13.0
python 3.6.5
Mac OS Sierra 10.12.6
Got same JavaScript error in:
Chrome Version 67.0.3396.87 (Official Build) (64-bit) and
Safari Version 11.1.1 (12605.2.8)

Description of expected behavior and the observed behavior

It should show a DataTable with checkboxes for row selection, as described in the DataTable help:

selectable = Either(Bool(True), Enum("checkbox"), help="""
    Whether a table's rows can be selected or not. Using ``checkbox`` is
    equivalent  to ``True``, but makes selection visible through a checkbox
    for each row,  instead of highlighting rows. Multiple selection is
    allowed and can be achieved by either clicking multiple checkboxes (if
    enabled) or using Shift + click on rows.

But nothing is shown, and a JavaScript error occurs, see below.

Complete, minimal, self-contained example code that reproduces the issue

from datetime import date
from random import randint

from bokeh.io import output_file, show
from bokeh.layouts import widgetbox
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import DataTable, DateFormatter, TableColumn

output_file("data_table.html")

data = dict(
            dates=[date(2014, 3, i+1) for i in range(10)],
            downloads=[randint(0, 100) for i in range(10)],
        )
source = ColumnDataSource(data)

columns = [
            TableColumn(field="dates", title="Date", formatter=DateFormatter()),
            TableColumn(field="downloads", title="Downloads"),
        ]
data_table = DataTable(source=source, columns=columns, width=400, height=280, selectable='checkbox')

show(widgetbox(data_table))

Stack traceback and/or browser JavaScript console output

Uncaught Error: Bool property 'selectable' given invalid value: "checkbox"
    at e.validate (bokeh-0.13.0.min.js:31)
    at e.t._init (bokeh-0.13.0.min.js:31)
    at e.t.update (bokeh-0.13.0.min.js:31)
    at e.u.finalize (bokeh-0.13.0.min.js:31)
    at bokeh-0.13.0.min.js:31
    at _ (bokeh-0.13.0.min.js:31)
    at _ (bokeh-0.13.0.min.js:31)
    at Function.P._initialize_references_json (bokeh-0.13.0.min.js:31)
    at Function.P.from_json (bokeh-0.13.0.min.js:31)
    at bokeh-0.13.0.min.js:31

Screenshots or screencasts of the bug in action

@2torus
Copy link
Contributor

@2torus 2torus commented Jul 4, 2018

@bryevdv I think the issue is the difference between data_table.ts line 277
and data_table.ts line 307
I think 307 should be selectable: [ p.Any, true]. Changing this worked for me.

@mattpap mattpap added this to the 1.0 milestone Jul 5, 2018
@bryevdv bryevdv closed this in #8051 Jul 5, 2018
bryevdv added a commit that referenced this issue Jul 5, 2018
…8051)

* Change type of the selectable property of DataTable to allow selectable be a checkbox

* formatting

* add comment on type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.