I use CustomJS to filter my table like the below code. it works fine
combined_callback_code = """
var data = source.data;
var original_data = original_source.data;
var account = account_select_obj.value;
console.log("account: " + account);
for (var key in original_data) {
data[key] = [];
for (var i = 0; i < original_data['D01_03_ZF_TRANSACTIONS_TRANS_NUM_ST'].length; ++i) {
if ((account === "ALL" || original_data['D01_03_ZF_TRANSACTIONS_TRANS_NUM_ST'][i] === account))
{
data[key].push(original_data[key][i]);
}
}
}
target_obj.change.emit();;
source.change.emit();
"""
df = collection("D01_04_RT_PHARMA_TRANS")
df1= collection("MAPPING_TABLE")
# Put dataframe to bokeh data source defined
data = dict(
D01_03_ZF_TRANSACTIONS_TRANS_NUM_ST= df["D01_03_ZF_TRANSACTIONS_TRANS_NUM_ST"]
)
source = ColumnDataSource(data)
original_source = ColumnDataSource(data)
account_list = ['ALL'] + df1["ZF_TRANSACTIONS_TRANS_NUM_ST"].unique().tolist()
account_select = Select(title="Account:", value=account_list[0], options=account_list)
def make_table_1():
# Generate table
columns = [
TableColumn(field="D01_03_ZF_TRANSACTIONS_TRANS_NUM_ST", title="CMI Pharma Account" ),
]
data_table = DataTable(source=source, columns=columns, width=1000, height=300)
# now define the callback objects now that the filter widgets exist
generic_callback = CustomJS(
args=dict(source=source,
original_source=original_source,
account_select_obj=account_select,
target_obj=data_table),
code=combined_callback_code
)
# finally, connect the callbacks to the filter widgets
account_select.js_on_change('value', generic_callback)
p = column(data_table, account_select)
return p
``
But my problem is that i don’t want to use
p = column(data_table, account_select)
``
Because i need to separate bokeh obj like this. Then add it to my html template.
@bp.route(’/table1’)
def table1():
return json.dumps(json_item(slider, “mytable1”))
@bp.route(’/filter1’)
def filter1():
return json.dumps(json_item(plot, “filter1”))
``
By doing that i got error ‘models must be owned by only a single document’ and the filter also not work. Is there a way to not using layout properties but the filter still work on multi plot ?