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

Add default_sort parameter to mo.ui.table #3860

Open
sarah-utilityapi opened this issue Feb 20, 2025 · 3 comments
Open

Add default_sort parameter to mo.ui.table #3860

sarah-utilityapi opened this issue Feb 20, 2025 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@sarah-utilityapi
Copy link

Description

I am hoping to be able to write the following code that would mean that a ui.table gets initially rendered with a sorted column.

mo.ui.table(data, default_sort='Title')

where 'Title' is the column name name of the.

By default it would be ascending.

We would need a mechanism to specify descending. Possible options

ascending=False  # like pandas
default_sort='-Title'  # like django
default_sort='ASC:Title' or default_sort='DESC:Title' 

If a user then subsequently sorts on a different column the default sort would be lost.

Suggested solution

I've sketched out an API above. I don't know about the under-the-hood implementation.

Alternative

No response

Additional context

No response

@sarah-utilityapi sarah-utilityapi added the enhancement New feature or request label Feb 20, 2025
@mscolnick
Copy link
Contributor

Why not sort the dataframe before passing it into the table? This way you'd have more flexibility with the sorting too

@sarah-utilityapi
Copy link
Author

When I was working with dataframes I was doing that. In this case I'm passing in a list of dictionaries that I've constructed with plain data and mo.ui components (such as making html link outputs.) In the light of morning, I'm realizing that I can sort this list, and will.

This is slightly lacking as a complete UX solution because it won't show to the user the sort that's been pre-applied. But it gets me out of my jam. Thanks!

@mscolnick
Copy link
Contributor

Got it, just wanted to understand the use-case (besides some logic), which is: show the user how the data is currently sorted. Thank you, this makes sense.

@mscolnick mscolnick added good first issue Good for newcomers help wanted Extra attention is needed labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants