Skip to content

Editing filtered DataTable cell impacts wrong row #8040

@jburgy

Description

@jburgy

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

bokeh 0.13.0, python 3.6.5, macOS High Sierra 10.13.4

Description of expected behavior and the observed behavior

Editing filtered DataTable cell impacts wrong row. Impacted cell is below targeted one when rows above it are filtered (DTINDEX_NAME/index_position confusion).

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 CDSView, ColumnDataSource, CustomJS, CustomJSFilter
from bokeh.models.widgets import DataTable, DateFormatter, NumberEditor, Slider, TableColumn

output_file("data_table.html")

threshold = Slider(title='Threshold', value=30, start=0, end=100, step=10)

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

filter_ = CustomJSFilter(args=dict(threshold=threshold), code='''
return source.data.downloads.map(x => x >= threshold.value)
''')

view = CDSView(source=source, filters=[filter_])

columns = [
    TableColumn(field="dates", title="Date", formatter=DateFormatter()),
    TableColumn(field="downloads", title="Downloads", editor=NumberEditor()),
]

table = DataTable(source=source, view=view, columns=columns, width=400, height=280, editable=True)

threshold.js_on_change('value', CustomJS(args=dict(view=view), code='''
view.compute_indices(view.source);
view.source.properties.data.change.emit()
'''))

show(widgetbox(threshold, table))

Increase value of a cell where index_position > current row, hit enter, and observe your new value appearing below the cell you edited.

Stack traceback and/or browser JavaScript console output

No error or warning in console.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions