Changing the filters of a CDSView doesn't update the DataTable?

Hi,
I don’t know if my issue is related to this one (In Bokeh Server, CDSView Is Updating But Glyph Does Not) or this one(Dynamically changing GroupFilter.group does not update table view) and if it was fixed in the meantime.
I have a datatable built in this way:

self._pakCDS = ColumnDataSource(dict())
self._pakCDSView = CDSView(source=self._pakCDS, filters=[])        
self._dataTable = DataTable(source=self._pakCDS, index_position=0, autosize_mode='fit_columns',
                                    view=self._pakCDSView, width=800, height=800)

When I use a textInput on_change callback to update the filters of the CDSView, nothing happens at the DataTable
I tried both this way:

def _apply_filter(self, attr, old, new):
    booleans = BooleanFilter([True if new in y_val else False for y_val in self._pakCDS.data['label']])
    self._pakCDSView.filters[0] = booleans

and this way:

def _apply_filter(self, attr, old, new):
    booleans = BooleanFilter([True if new in y_val else False for y_val in self._pakCDS.data['label']])
    self._pakCDSView.filters = [booleans]

but nothing works.

It’s not possible to speculate since you have not stated what version of Bokeh you are using. It’s also always advised to provide a Minimal Reproducible Example to help others help you.

Hi Bryan,
my bokeh version is the 2.2.3 and here’s a working example.
I would expect that when I click the button only the first row gets displayed on the datatable:

import pandas as pd
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource, CDSView, BooleanFilter, DataTable, TableColumn
from bokeh.models.widgets import Button
from bokeh.layouts import row


def update_plot():
    view.filters = [BooleanFilter([True, False, False])]
    print(view.source.data)
    print(view.filters[0].booleans)


f = {'mydates': [19123, 19124, 19125],
     'myvalues': [34, 41, 12]}
fim = pd.DataFrame(data=f)

filterbutton = Button(label="Filter")

src = ColumnDataSource(fim)
view = CDSView(source=src, filters=[])
columns = ['mydates', 'myvalues']
p = DataTable(columns=[TableColumn(field=Ci, title=Ci) for Ci in columns], source=src, view=view)

filterbutton.on_click(update_plot)

layout = row(p, filterbutton)
curdoc().add_root(layout)
curdoc().title = "please.. work!!!"

Thanks

I did another trial, with the plot, well changing the boolean filter of the CDSview triggers the update of the plot but not the update of the datatable:

import pandas as pd
import numpy as np
from bokeh.io import curdoc
from bokeh.plotting import figure
from bokeh.models import  ColumnDataSource, CDSView, GroupFilter, DataTable, TableColumn
from bokeh.models.widgets import Select
from bokeh.layouts import row


def update_plot(attr, old, new):
    view.filters[0] = GroupFilter(column_name='stupid_label', group=stupidlabel.value)


def make_plot(fim):
    TOOLS = "save,pan,box_zoom,reset,wheel_zoom"
    p = figure(title="the plot that makes me mad !", plot_width=800, plot_height=400,tools=TOOLS)
    p.line(fim.mydates,fim.myvalues,color='blue')
    return p


f = {'mydates': [19123, 19124, 19125, 19126, 19127, 19128, 19129, 19129, 19130],
     'myvalues': [34, 41, 12, 7, 27, 40, 32, 11, 1],
     'stupid_label': ['POUET', 'POUET', 'BANZAI', 'BANZAI', 'BANZAI', 'YOUPI', 'YOUPI', 'POUET', 'POUET']}

fim = pd.DataFrame(data=f)
p = make_plot(fim)

u_stupid_label=np.unique(fim.stupid_label)
stupidlabel = Select(value=u_stupid_label[0], options=list(u_stupid_label))

src= ColumnDataSource(fim)
view = CDSView(source=src,filters=[GroupFilter(column_name='stupid_label', group=stupidlabel.value)])
p.circle('mydates','myvalues',source=src,view=view,color='black')
columns = ['mydates', 'myvalues', 'stupid_label']
pp = DataTable(columns=[TableColumn(field=Ci, title=Ci) for Ci in columns], source=src, view=view)

stupidlabel.on_change('value', update_plot)

layout = row(pp, p, stupidlabel)
curdoc().add_root(layout)
curdoc().title = "please.. works !!!"

While waiting for this bug to be fixed, when the filter is updated I trigger the update of the dataTable by:
dataTable.visible = False
dataTable.visible = True