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

Sorting On Grouped Tables With Multiple defaultSorted #339

Open
rdesalvio opened this issue Sep 28, 2023 · 1 comment
Open

Sorting On Grouped Tables With Multiple defaultSorted #339

rdesalvio opened this issue Sep 28, 2023 · 1 comment

Comments

@rdesalvio
Copy link

I noticed that when you have a grouped table with a 2 sorts defined, the table appears properly on first load. But, when you click on any column to sort, the secondary sort is discarded and you cannot get that back. It feels like there should be a way to maintain that secondary sort after first load. Perhaps this isn't something that should be enabled by default, but it feels like it should be possible considering there are sort type hints and the sorting works on first load.

There probably is some way to fix this with JavaScript(I would love if anyone were able to accomplish this and show me as my javascript definitely leaves something to be desired), but again, I feel like the library should have a setting in colDef perhaps that is able to maintain that secondary sort.

Small code example:

reactable(df, 
                groupBy=c('System'),
                defaultSorted = list(Total='desc', group_num='asc'),
                group_num=colDef(show=FALSE)
)

Would love to have that secondary group_num field maintain its sort status, even though it is not visible.

@glin
Copy link
Owner

glin commented Oct 2, 2023

So I'm not 100% sure I understood correctly, but I think what may be looking for is the multi-sort feature when you hold the Shift key while sorting: https://glin.github.io/reactable/articles/examples.html#sorting

When you hold Shift, the sorted column changes sort order while maintaining all other column sorting.

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