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 with frozen_rows scrolling/paging to top when updating content #6800

Closed
sylvaint opened this issue Apr 29, 2024 · 5 comments · Fixed by #7084
Closed

Tabulator with frozen_rows scrolling/paging to top when updating content #6800

sylvaint opened this issue Apr 29, 2024 · 5 comments · Fixed by #7084
Labels
component: tabulator Related to the Tabulator widget
Milestone

Comments

@sylvaint
Copy link

sylvaint commented Apr 29, 2024

ALL software version info

panel 1.4.2

Description of expected behavior and the observed behavior

With Tabulator using pagination and frozen_rows.
When updating the data, the page snaps back to page 1 regardless of where the paging was whenever the update comes. Removing the frozen row, it behaves as expected.

Same behavior without paging using a scrollbar in Tabulator instead.

Also same behavior when using patch instead of writing the complete dataframe.

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

import panel as pn
import numpy as np
import pandas as pd

pn.extension('tabulator')

def create_random_dataframe(n_rows):
    """Create a DataFrame with n_rows and 5 columns, where the first column is a constant 1 to n_rows and the rest are filled with random numbers."""
    # Define the column names
    columns = ['A', 'B', 'C', 'D', 'E']
    # Generate a DataFrame with the first column being 1 to n_rows and the rest random
    df = pd.DataFrame(np.random.rand(n_rows, 4), columns=columns[1:])
    df.insert(0, 'A', range(1, n_rows + 1))  # Insert the constant column at position 0 with values 1 to n_rows
    return df

df_data = create_random_dataframe(50)

# with frozen_rows 0, Tabulator will snap back to page 1 at every update
df_tab = pn.widgets.Tabulator(df_data,hidden_columns=['index'], layout='fit_data_fill', frozen_rows=[0], sortable=False, disabled=True, pagination='local', page_size=10)

# without frozen_rows set to 0 Tabulator will remain in whatever page it was after an update
# df_tab = pn.widgets.Tabulator(df_data,hidden_columns=['index'], layout='fit_data_fill', sortable=False, disabled=True, pagination='local', page_size=10)

def update_data():
    df_data = create_random_dataframe(50)
    df_tab.value = df_data

pn.state.add_periodic_callback(update_data, period=2000, start=True)

layout = pn.template.FastListTemplate(
    site="my site",
    title="Tabulator",
    accent_base_color='#d78929',
    header_background='#d78929',
    main=[pn.Column(df_tab)],
)
layout.servable()

Screenshots or screencasts of the bug in action

tabulator_paging.mp4
tabulator_scroll_floatpanel.mp4
@philippjfr
Copy link
Member

To avoid the reset here you should stream data and set the rollover:

def update_data():
    df_tab.stream(create_random_dataframe(50), follow=True, rollover=50)

@sylvaint
Copy link
Author

sylvaint commented Aug 6, 2024

Thank you so much for this. I will try this shortly.

@philippjfr
Copy link
Member

Oh sorry, I should have said, that also doesn't behave properly as of right now but #7084 will fix that.

@sylvaint
Copy link
Author

sylvaint commented Aug 6, 2024

Got it thanks. Will monitor #7084

@sylvaint
Copy link
Author

Same issue as before. Streaming with follow is not a solution.
This is the desired behavior but it does not work with a frozen row:

Screen.Recording.2024-09-20.at.5.11.10.PM.mov

Even better if it would work without paging and a scrollbar.

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.

3 participants