Skip to content

Getting values of selected rows from a DataTable after reordering with sort #3564

@jms90h5

Description

@jms90h5

I'm trying to find a way to query the values on selected rows of a DataTable after it has been sorted by clicking on one of the column headers.

Before the table row order gets modified by the sort operation I could use the selected indexes available in a CustomJS callback to get the values contained in the selected rows from the ColumnDataSource used as input to the table. However, when the table rows are reordered with a sort those selection indexes relate to the new order of the rows that are displayed. (i.e. the order oder of the source stays the same but the display order is different.) The reported selection indexes correctly match the display order (e.g. if the third row is selected a selection index of 2 will be reported). However, I can't figure out how to get the values that are displayed on that row since it now isn't the third row of the input data source.


Bryan Van de ven commented:

Looking at the current code:

https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/widgets/data_table.coffee#L52-L86

It looks like it actually is trying to update the data source order. I'm not sure how I feel about that. I think maybe I hope that doesn't work, I think a better approach would be to maintain an explicit sorter to use to map to the original data.


My initial reaction is that I agree with Bryan that actually reordering the data source might not be a great idea. However a bit more investigation shows that the data source is not actually being reordered. Either that or the reordered one is not getting exposed to either the javascript in the callback or python executing in a jupyter notebook.

I should add that I've been testing this on v.11RC2 but will try with the released one also.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions