I figured out one way to do this, by having CustomJS change SelectEditor.options, triggered on indices selected. So here is my code, that gives me different dropdown options on each row.
from bokeh.models import ColumnDataSource
from bokeh.models.widgets.tables import (
DataTable, TableColumn, SelectEditor
)
from bokeh.io import curdoc
from bokeh.models import CustomJS
# sample data
table_data = {
'x': ["1", "2", "3"]
}
default_options = [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"
]
# on every source.select event,
# change the options according to the row number
full_options = [
["1", "2", "3"],
["4", "5", "6"],
["7", "8", "9"]
]
source = ColumnDataSource(data=table_data)
# need a reference to the SelectEditor,
# to change editor.options later
editor = SelectEditor(options=default_options)
columns = [
TableColumn(field="x", title="x", editor=editor)
]
data_table = DataTable(
source=source,
columns=columns,
editable=True
)
callback = CustomJS(args={"editor": editor, "full_options": full_options}, code="""
n = cb_obj.indices[0];
editor.options = full_options[n]
""")
source.selected.js_on_change("indices", callback)
curdoc().add_root(data_table)
But this seems like not the right way to do this. Is there a better way to implement this feature? Are there any obvious shortcomings of this implementation?