Bokeh JS callback to select table rows based on selection from another table

242 Views Asked by At

I have two bokeh tables and I would like to click on a table record in the first table and select rows in the second table based on matching values from in the field. created a js callback script to:

Create an empty list to hold indices from table2 that match records in table 1 collected to selected indices of table 1

Loop over the indices in table 1 and collect value to compare to table 2 loop over table 2 and append the indices if the table id's match.

Nothing is happening when I run the script and select on the table.

code = """
    var select_indices = []
    var cdata = cb_obj.data;
    var pdata = psrc.data;
    var indices = cb_obj.selected.indices;

    for (var i=0; i < indicies.length; i ++){
        var hh_id = cdata['hh_id'][i]

        for (var j = 0; j < pdata['hh_id'].length; j++){

            if(pdata['hh_id'][j] == hh_id){
                select_indices.push(j)
            }
        }

    }

    psrc.selected.indices = select_indices;
    psrc.trigger('change');

"""


hh_src.callback = CustomJS(args=dict(psrc=per_src), code=code)

Page image

error from console window

VM544 bokeh-0.13.0.min.js:31 Uncaught Error: not connected so cannot send 
[object Object]
at t.send (VM78 bokeh-0.13.0.min.js:31)
at t._document_changed (VM78 bokeh-0.13.0.min.js:31)
at _document_listener (VM78 bokeh-0.13.0.min.js:31)
at P._trigger_on_change (VM78 bokeh-0.13.0.min.js:31)
at P._notify_change (VM78 bokeh-0.13.0.min.js:31)
at t.u._tell_document_about_change (VM78 bokeh-0.13.0.min.js:31)
at t.u.setv (VM78 bokeh-0.13.0.min.js:31)
at t.set [as indices] (VM78 bokeh-0.13.0.min.js:31)
at SlickGrid.<anonymous> (VM80 bokeh-tables-0.13.0.min.js:31)
at Event.notify (VM80 bokeh-tables-0.13.0.min.js:68)
t.send  @   VM544 bokeh-0.13.0.min.js:31
t._document_changed @   VM544 bokeh-0.13.0.min.js:31
_document_listener  @   VM544 bokeh-0.13.0.min.js:31
P._trigger_on_change    @   VM544 bokeh-0.13.0.min.js:31
P._notify_change    @   VM544 bokeh-0.13.0.min.js:31
u._tell_document_about_change   @   VM544 bokeh-0.13.0.min.js:31
u.setv  @   VM544 bokeh-0.13.0.min.js:31
set @   VM544 bokeh-0.13.0.min.js:31
(anonymous) @   VM546 bokeh-tables-0.13.0.min.js:31
Event.notify    @   VM546 bokeh-tables-0.13.0.min.js:68
trigger @   VM546 bokeh-tables-0.13.0.min.js:86
handleSelectedRangesChanged @   VM546 bokeh-tables-0.13.0.min.js:86
Event.notify    @   VM546 bokeh-tables-0.13.0.min.js:68
f   @   VM546 bokeh-tables-0.13.0.min.js:68
h   @   VM546 bokeh-tables-0.13.0.min.js:68
(anonymous) @   VM546 bokeh-tables-0.13.0.min.js:68
 Event.notify   @   VM546 bokeh-tables-0.13.0.min.js:68
trigger @   VM546 bokeh-tables-0.13.0.min.js:86
setActiveCellInternal   @   VM546 bokeh-tables-0.13.0.min.js:86
handleClick @   VM546 bokeh-tables-0.13.0.min.js:86
dispatch    @   jquery.min.js:2
h.dispatch  @   VM85 bokeh-tables-0.13.0.min.js:62
y.handle    @   jquery.min.js:2
0

There are 0 best solutions below