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

Column default sort order does not override global default #25

Closed
dhimmel opened this issue Nov 20, 2024 · 6 comments
Closed

Column default sort order does not override global default #25

dhimmel opened this issue Nov 20, 2024 · 6 comments

Comments

@dhimmel
Copy link

dhimmel commented Nov 20, 2024

Amazing package! Extremely powerful and functional for its star count. I sense a bright future here.

Similar to this example but without setting default_sorted:

import reactable
from reactable.data import penguins
import polars as pl

reactable.embed_css()

pl_penguins = penguins.to_polars()
reactable.Reactable(
    pl_penguins,
    default_sort_order="desc",
    columns=[reactable.Column(id="species", default_sort_order="asc")],
)

The first time I click on the species header, that columns sorts descending (along with all other columns). The expected behavior is for species to first sort ascending because the Column sets default_sort_order="asc".

Seems to work at https://glin.github.io/reactable/articles/examples.html#default-sort-order

@machow
Copy link
Owner

machow commented Nov 21, 2024

Hey @dhimmel, long time no see! Shoot, thanks for reporting -- it looks currently we handle the initial sort order, but need to add a Column.default_sort_desc property to say what should happen when resorting 😓

@dhimmel
Copy link
Author

dhimmel commented Nov 21, 2024

long time no see!

haha yes! @trangdata told me about R reactable and then we saw you're making a python client.

it looks currently we handle the initial sort order, but need to add a Column.default_sort_desc property to say what should happen when resorting

I figured Column.default_sort_order would control both the initial sorting for columns in default_sorted and then subsequent first sorting actions on columns not in default_sorted.

@machow
Copy link
Owner

machow commented Nov 21, 2024

haha yes! @trangdata told me about R reactable and then we saw you're making a python client.

ah nice!

Sorry, I should have been clearer that it's a bug in reactable-py :/, but should be fixed in the v0.1.3 release just now!

@dhimmel
Copy link
Author

dhimmel commented Nov 21, 2024

Cool thanks for #26. The following code using a default_col_def now does what I want, which is the first time you click on any column it sorts descending, except for species which sorts ascending on first click:

reactable.Reactable(
    pl_penguins,
    default_col_def=reactable.Column(default_sort_order="desc"),
    columns=[reactable.Column(id="species", default_sort_order="asc")],
)

I don't think the global default_sort_order method is working though in v0.1.3 because columns other than species are not sorting descending upon first click:

reactable.Reactable(
    pl_penguins,
    default_sort_order="desc",
    columns=[reactable.Column(id="species", default_sort_order="asc")],
)

Anyways, I'm all good since the default_col_def method is working!

@machow
Copy link
Owner

machow commented Nov 22, 2024

shoot :/, the table sorting default behavior should be fixed now in https://github.com/machow/reactable-py/releases/tag/v0.1.4

@dhimmel
Copy link
Author

dhimmel commented Nov 23, 2024

Confirming that both examples now work as expected. Thanks!

@dhimmel dhimmel closed this as completed Nov 23, 2024
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

No branches or pull requests

2 participants