I am trying to use CDSView with a GroupFilter(…) instance in a DataTable. It looks like an awesome abstraction. But I have some trouble make it work for my dynamic case.
The initial view is properly filtered per my initial group specifier. I have a Select() widget which I wanted to use to control which group is displayed in the table. I tried both Python side and JS side linking, and I verified that the view’s group attribute gets updated. But the table does not update.
Is this supposed to work? Am I missing something? Bug? Unfinished feature?
Relevant code:
options = sorted(df.col1.unique())
select = Select(title='Please chose:', value=options[0], options=options)
cds = ColumnDataSource(df)
group_filter = GroupFilter(column_name='col1', group=select.value)
view = CDSView(source=cds, filters=[group_filter])
columns = [TableColumn(filter=n, title=n) for n in df.columns]
table = DataTable(columns=columns, source=cds, view=view)
I tried to link the selection in the following two ways, none of them achieving an update to the table upon selection change:
Python side:
select.on_change('value', lambda a, o, n: group_filter.update(group=n))
Browser side:
select.js_link('value', group_filter, 'group')