Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when editing a cell in a client-side filtered column #3831

Closed
maximlt opened this issue Sep 14, 2022 · 0 comments · Fixed by #3852
Closed

Error when editing a cell in a client-side filtered column #3831

maximlt opened this issue Sep 14, 2022 · 0 comments · Fixed by #3852
Labels
component: tabulator Related to the Tabulator widget

Comments

@maximlt
Copy link
Member

maximlt commented Sep 14, 2022

I just found out that an error is raised now when trying to update a cell in a column that is filtered by a header filter. This is because Tabulator implements _process_data to apply the header filters to data. This was done to fix some other bug, except that in this case after being filtered data can no longer be compared as it's one row smaller than the old data, as the row with the edited value is filtered out...

panel/panel/widgets/tables.py

Lines 1209 to 1230 in e43b8c5

def _process_data(self, data):
# Extending _process_data to cover the case when header filters are
# active and a cell is edited. In that case the data received from the
# front-end is the full table, not just the filtered one. However the
# _processed data is already filtered, this made the comparison between
# the new data and old data wrong. This extension replicates the
# front-end filtering - if need be - to be able to correctly make the
# comparison and update the data hold by the backend.
if not self.filters:
return super()._process_data(data)
import pandas as pd
df = pd.DataFrame(data)
filters = self._get_header_filters(df)
if filters:
mask = filters[0]
for f in filters:
mask &= f
df = df[mask]
data = {
col: df[col].values for col in df.columns
}
return super()._process_data(data)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tabulator Related to the Tabulator widget
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants