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

Tabulator selection value not updating in Voila app #3963

Open
dcnadler opened this issue Oct 5, 2022 · 2 comments
Open

Tabulator selection value not updating in Voila app #3963

dcnadler opened this issue Oct 5, 2022 · 2 comments
Labels
component: tabulator Related to the Tabulator widget type: bug Something isn't correct or isn't working

Comments

@dcnadler
Copy link

dcnadler commented Oct 5, 2022

ALL software version info

Docker image: python:3.9

panel==0.14.0
bokeh==2.4.3
jupyter-bokeh==3.0.5
jupyter-core==4.11.1
jupyter-server==1.19.1
jupyter_client==7.3.5
jupyterlab_server==2.15.2

tested both:
voila==0.3.6
ipywidgets==7.7.2
and
voila==0.4.0a2
ipywidgets==8.0.2

Description of expected behavior and the observed behavior

When using a Tabulator widget in a voila app, the selection and selected_dataframe attribute values do not change from the initial values even when the front-end selection changes.

Complete, minimal, self-contained example code that reproduces the issue

.ipynb file that's served with voila:

import pandas as pd
from IPython.display import display, Markdown
import ipywidgets as ipw
from ipywidgets import VBox
import panel as pn
pn.extension('tabulator')
df = pd.DataFrame({'a': [1, 2, 3, 4], 'b': [5, 6, 7, 8], 'c': [9, 10, 11, 12]})

show_btn = ipw.Button(description = 'Show Selection')

table_widget = pn.widgets.Tabulator(df, selectable='checkbox')

output = ipw.Output()

@output.capture(clear_output = True)
def display_selection(b):
    print('Selected dataframe')
    print(table_widget.selected_dataframe)
    print('-------')
    print('Selection')
    print(table_widget.selection)
        
show_btn.on_click(display_selection)

display(Markdown("## Test tabulator"))

display(VBox([pn.ipywidget(table_widget), show_btn, output]))

The initial table has no selection and when rows are selected and the callback is triggered, the printed output still has no selection:

Selected dataframe
Empty DataFrame
Columns: [a, b, c]
Index: []
-------
Selection
[]

However, if this notebook is run in JupyterLab (not voila) the selection is reflected in the output:

Selected dataframe
   a  b   c
1  2  6  10
2  3  7  11
-------
Selection
[1, 2]

Thanks!

@hhlim333
Copy link

hhlim333 commented Sep 6, 2023

Anyone to solve this problem?

@maximlt maximlt added type: bug Something isn't correct or isn't working component: tabulator Related to the Tabulator widget labels Nov 14, 2023
@Kalandoros
Copy link

I can confirm there is a bug as described by dcnadler.
I also became aware that the on_click callback seems generally not to work in voila whereas it does in Jupyterlab.
Maybe it is the right approach to look for on_click as the root cause.

Python: 3.11.5
panel==0.3.6
bokeh==3.2.2
jupyter-bokeh==3.0.7
jupyter-core==5.3.0
jupyter-server==2.7.3
jupyter_client==8.1.0
jupyterlab_server==2.25.0
voila==0.5.5
ipywidgets==8.1.1

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 type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

4 participants