question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting Selected Property of ColumnData does not Change Selected Row.

See original GitHub issue

To get the selected rows of a DataTable you access the property source.selected['1d']['indices']. I tried to set the property so selection is based on code, but it doesn’t work. What other way do I have to set the selected rows (preferably with python not JS) ? In the example below, based on the documentation, I set the selected row to be equal 3 but the table is not selected in the browser.

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)
source.selected['1d']['indices'] = [3]
show(widgetbox(data_table))

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bryevdvcommented, May 10, 2018

This was fixed at some point. Original code with update for selected.indices:

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)
source.selected.indices= [3]
show(widgetbox(data_table))

yields:

screen shot 2018-05-10 at 12 03 41
0reactions
bryevdvcommented, May 17, 2018

@BCoat no worries, we just try to keep the tracker reserved for bugs and feature requests, and leave other questions to the mailing list (or SO, gitter)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preserve JTable selection across TableModel change
You need to preserve the selection and then re-apply it. First of all you will need to get a list of all the...
Read more >
Change the source data for a PivotTable - Microsoft Support
Change the source data · Click select a Use an external data source, and then click Choose Connection. · In the Show drop-down...
Read more >
Row Selection - JavaScript Data Grid
Configure row selection with the following properties: rowSelection : Type of row selection, set to either 'single' or 'multiple' to enable selection. 'single' ......
Read more >
How to highlight active row and column in Excel - Ablebits
In this tutorial, you will learn 3 different ways to dynamically highlight the row and column of a selected cell in Excel.
Read more >
Row Selection - Tabulator
Row selection allows users to select and highlight a number of rows that you can then take action on. This allows rows to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found