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).

2 Likes

@Mehmet @Hoxbro is the selection-persist with larger DataFrames a bug? I’m trying to use it with >70k rows. Very impressive how well it performs sorting, etc with that many rows, but I really need the selections to persist when switching between pages if possible.

1 Like

Hi @CrashLandonB

If its not persisting, please make a feature request.

Most likely a bug, if you don’t find an existing issue feel free to open one, if there’s one feel free to add a comment in there :slight_smile:

Here’s a MRE:

import panel
import pandas
import numpy

data = numpy.random.random((300,6))
df = pandas.DataFrame(data)
tab = panel.widgets.Tabulator(value=df, sizing_mode='fixed', disabled=True, pagination='remote', page_size=25,
                              selectable='checkbox', header_filters=True)
panel.serve(tab)

With the example above, if Iselect a few rows, change pages, select a few more rows, and return to the original page, I don’t see the rows selected any longer.

Can anyone try and confirm? If confirmed I’ll submit a bug.

I’m using panel v0.14.1

@Marc @maximlt

There was a bug related to persistence of the selected rows and it’s fixed AFAIK. Could you try with the latest version?

I can confirm it is a bug. A bug report would be highly appreciated. :slight_smile:

1 Like

Bug submitted here:

Thanks all!