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

Enable selection across different pages with pagination="remote" and selectable="checkbox" #5889

Merged
merged 15 commits into from
Nov 21, 2023

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Nov 17, 2023

Fixes #4367

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

pn.extension("tabulator")

data = np.arange(20) + 100
df = pd.DataFrame(data)
tab = pn.widgets.Tabulator(
    value=df,
    disabled=True,
    pagination="remote",
    page_size=10,
    selectable="checkbox",
    header_filters=True,
)
tab.servable()
screenrecord-2023-11-17_17.17.53.mp4

@hoxbro hoxbro marked this pull request as draft November 17, 2023 15:37
Copy link

codecov bot commented Nov 17, 2023

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (f0b1832) 84.41% compared to head (ab16e1c) 84.15%.
Report is 3 commits behind head on main.

Files Patch % Lines
panel/widgets/tables.py 72.00% 7 Missing ⚠️
panel/models/tabulator.py 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5889      +/-   ##
==========================================
- Coverage   84.41%   84.15%   -0.26%     
==========================================
  Files         291      291              
  Lines       42655    42764     +109     
==========================================
- Hits        36007    35988      -19     
- Misses       6648     6776     +128     
Flag Coverage Δ
ui-tests 40.95% <85.24%> (+0.12%) ⬆️
unitexamples-tests 72.41% <17.21%> (-0.44%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hoxbro hoxbro marked this pull request as ready for review November 20, 2023 14:02
@hoxbro hoxbro changed the title Remote multipage selection Enable selection across different pages with pagination="remote" and selectable="checkbox Nov 21, 2023
@hoxbro hoxbro changed the title Enable selection across different pages with pagination="remote" and selectable="checkbox Enable selection across different pages with pagination="remote" and selectable="checkbox" Nov 21, 2023
Copy link
Member

@maximlt maximlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left some comments. I have noticed that when selecting all the rows with the tickbox that is in the header, it selects the rows of the displayed page only. The behavior with local pagination is to select all the rows. Is that on purpose?

Very happy to see these many UI tests! 👍


event_name = 'selection-change'

def __init__(self, model, indices, selected):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of indices, selected, how about having selected, deselected, each one of the latter being a list (empty or not) of indices? Asking since it wasn't first obvious to me what selected would hold.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not the biggest fan of the names I have chosen.

Your suggestion could also be confusing since the indices are only updated ones and not a full list of selected/deselected indices.

@philippjfr, any preferences?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real preference, a comment to clarify is probably more important than the naming here since these events won't be user facing.

panel/widgets/tables.py Show resolved Hide resolved
panel/widgets/tables.py Show resolved Hide resolved
@philippjfr
Copy link
Member

@hoxbro My main question is whether the title is still accurate? The idea was to support cross-page selection for all selection modes, not just the "checkbox" mode, but I'd be happy if your answer was that you will follow up in another PR.

@hoxbro
Copy link
Member Author

hoxbro commented Nov 21, 2023

I have noticed that when selecting all the rows with the tickbox that is in the header, it selects the rows of the displayed page only. The behavior with local pagination is to select all the rows. Is that on purpose?

Not more than that was how it manifested itself when clicking on the top tickbar. It made sense to me that it would only select the current page, as this is how it works in apps like Gmail.

My main question is whether the title is still accurate? The idea was to support cross-page selection for all selection modes, not just the "checkbox" mode, but I'd be happy if your answer was that you will follow up in another PR.

The title should still be accurate as selectable=True goes down a different function in TypeScript this.rowClicked, where change here is done in this.rowSelectionChanged.

Don't worry; I will add this in another PR 🙂

https://github.com/holoviz/panel/pull/5889/files#diff-62ea1172d9fa28fbf400f9dae9e61bf030147840e9c9efe43d95287c653a4b63L479

@philippjfr philippjfr merged commit 8752779 into main Nov 21, 2023
13 checks passed
@philippjfr philippjfr deleted the tabulator_sel branch November 21, 2023 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tabulator row selection does not persist when changing pages
3 participants