holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.76k stars 517 forks source link

add range slider to tabulator as filter , but it does not work in the html file #6225

Closed 2beetle closed 9 months ago

2beetle commented 9 months ago

ALL software version info

(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc) python 3.9 panel 1.3.6

I try to add the range slider to tabulator so I can get the number in the range I want, but when i use the save method turn the app to html, the range slider lost the filtering effect

import panel as pn
import pandas as pd

pn.extension('tabulator')
df_2_0_2 = pd.read_excel('xxx.xlsx')
slider = pn.widgets.RangeSlider(start=df_2_0_2['Het_alt_number'].min(), end=df_2_0_2['Het_alt_number'].max(), name='Het_alt_number Filter')
table2_0_2 = pn.widgets.Tabulator(df_2_0_2,
                                  theme='bootstrap4',
                                  disabled=True,
                                  width=600, show_index=False, layout="fit_data_stretch",
                                  frozen_columns=['Sample'],
                                  header_filters=True,
                                  header_align='center',
                                  text_align='center')
table2_0_2.add_filter(slider, 'Het_alt_number')

row = pn.Row(slider, table2_0_2)
row.servable()
row.save('/Users/be/Desktop/panel_test/analysis_of_heterotic_groups_in_maize_test.html')
philippjfr commented 9 months ago

The add_filter functionality (like most of Panel) depends on a server to be available. In theory you may be able to implement this using .jscallback functionality but I will mark this as wontfix as it is out of scope.

2beetle commented 9 months ago

The add_filter functionality (like most of Panel) depends on a server to be available. In theory you may be able to implement this using .jscallback functionality but I will mark this as wontfix as it is out of scope.

get it. Thanks

2beetle commented 9 months ago

The add_filter functionality (like most of Panel) depends on a server to be available. In theory you may be able to implement this using .jscallback functionality but I will mark this as wontfix as it is out of scope.

I got the tabulator dom but i have no idea changing the data of it. Can i get some help? @philippjfr

table2_0_2 = pn.widgets.Tabulator(df_2_0_2,
                                  theme='bootstrap4',
                                  disabled=True,
                                  width=600, show_index=False, layout="fit_data_stretch",
                                  frozen_columns=['Sample'],
                                  header_filters=True,
                                  header_align='center',
                                  text_align='center')
slider.jscallback(args={'dataframe': df_2_0_2, 'table': table2_0_2}, value="")
2beetle commented 9 months ago

The add_filter functionality (like most of Panel) depends on a server to be available. In theory you may be able to implement this using .jscallback functionality but I will mark this as wontfix as it is out of scope.

I got the tabulator dom but i have no idea changing the data of it. Can i get some help? @philippjfr

table2_0_2 = pn.widgets.Tabulator(df_2_0_2,
                                  theme='bootstrap4',
                                  disabled=True,
                                  width=600, show_index=False, layout="fit_data_stretch",
                                  frozen_columns=['Sample'],
                                  header_filters=True,
                                  header_align='center',
                                  text_align='center')
slider.jscallback(args={'dataframe': df_2_0_2, 'table': table2_0_2}, value="")

I have solved it