Skip to content

Tabulator does not automatically update the screen content when using streaming and remote pagination #7721

Description

@malemburg

ALL software version info

Panel 1.6.1

Description of expected behavior and the observed behavior

When updating the table content using the .stream() method, Tabulator will normally automatically update the screen content with the new data.

This does happen when using the "local" pagination option, but it fails to do so with the "remote" pagination option. The screen only updates when e.g. clicking a header filter or sorting a column.

As a work-around, it's possible to reset the complete dataframe after calling .stream(), e.g. table.value = table.value, but that's not really the point, since .stream() is meant as an optimization.

Another trick is to temporarily update the table.pagesize, e.g. table.pagesize -=1; table.pagesize += 1, but this has some other undesired (visual) side-effects.

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

import panel as pn
import pandas as pd

def tabulator_test_case(case=1, pagination='remote', add_method=1, work_around=0):

    # Create a sample dataframe
    data = pd.DataFrame({
        'Name': ['Alice', 'Bob', 'Charlie'],
        'Age': [25, 30, 35],
        'City': ['New York', 'London', 'Paris']
    })

    # Create a Tabulator widget
    tabulator = pn.widgets.Tabulator(
        data,
        pagination=pagination,
        page_size=10,
        )

    # Action button
    add_row_button = pn.widgets.Button(
        name='Add Row',
    )
    def add_row(event):
        if add_method == 1:
            # Add row via .stream()
            tabulator.stream({
                'Name': [''],
                'Age': [0],
                'City': [''],
            })
        else:
            # Add row directly to data
            data.loc[len(data)] = ['', '', '']
        if work_around == 1:
            tabulator.value = tabulator.value
    add_row_button.on_click(add_row)

    # Create the layout
    layout = pn.Column(
        f"# Tabulator Demo {case}: {pagination=}, {add_method=}, {work_around=}",
        tabulator,
        add_row_button,
    )

    # Serve the app
    layout.servable()

 # works fine:
tabulator_test_case(1, pagination='local')

 # does not work - table doesn't update at all:
tabulator_test_case(2, pagination='local', add_method=2)

# table updates only after sorting:
tabulator_test_case(3, pagination='remote')

# works fine:
tabulator_test_case(4, pagination='remote', work_around=1)

# table updates only after sorting:
tabulator_test_case(5, pagination='remote', add_method=2)

# works fine:
tabulator_test_case(6, pagination='remote', add_method=2, work_around=1)

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

  • I may be interested in making a pull request to address this

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions