Selection of rows is not persisted when Tabulator is sorted?

Hi,

I think I’ve spotted a bug (or several bugs) in the Tabulator widget around the selection feature.

I’m using Panel 0.12.4 on Python 3.9.6 on Windows 10.

Here is the code to reproduce the issue:

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

    pn.extension("tabulator")

    dates = pd.date_range(
        start=np.datetime64("2021-09-01"), end=np.datetime64("2021-10-30")
    )
    numbers = pd.Series(np.arange(100, 160))
    df = pd.DataFrame({"Dates": dates, "Numbers": numbers})

    table = pn.widgets.Tabulator(
        df,
        name="Dates",
        disabled=True,
        show_index=False,
        selectable="checkbox",
        pagination="remote",
        page_size=10,
    )

    row = pn.Row(table)
    pn.serve(
        row.servable(),
        title=f"REPRO",
    )

Steps to reproduce:

  1. Run the above code.
  2. Select a few rows in the table.
  3. Click the Numbers column header to sort the table by it in descending order.
  4. Click it again to sort by descending order.

Actual behavior:
The rows you selected are no longer selected.

Expected behavior:
The rows should remain selected regardless of the order in which the table is sorted.

Here’s an animated gif of what I’m experiencing:

U3CQhyXDFB

Two additional unexpected behaviors:

  1. Occasionally the dates in the Dates column turn into seconds since unix epoch time.
  2. Occasionally the paging buttons stop working.

Are these one or more bugs or am I missing something in my code? Should I open GitHub issues for these? If they’re bugs, I’d like to help fix them.

Thanks,
urig

I’m having the similar issue. Selection of rows are not persisted when I switch to other pages in the table. Have you found a solution?

@Mehmet Have you updated to the latest panel version 0.13.1?

If you have and still see the problems try to install the latest dev release with either pip install panel==0.14.0a21 --pre or conda install panel=0.14 -c pyviz/channel/dev.

If you still see the problem make an issue on Github with an MRE.

Yes, I’m using the latest version and I think I found the main issue. When the DataFrame has less rows(3000), persisted view works OK. When there are 50000 rows, it doesn’t persist the selections. I guess this is related to pagination(I haven’t set a pagination parameter, btw).

1 Like