Custom Sort for Table Group By

Currently when grouping a table by a column there are sort options of ascending or descending. I would like to be able to define a custom sort order.

1 Like

Noted, thank you! Do you have any specific examples of a custom sort order?

In my use case we want to group the appointments by status. The status options include: unscheduled, scheduled, closed, invoiced, canceled, etc. We would like to customize the order which these groups are displayed.

Thank you so much! I went ahead and shared that with the eng team working on our Table component.

2 Likes

@victoria
Any news regarding this?

We do have these new(ish) docs on column sorting! https://docs.retool.com/apps/web/guides/components/table#column-sort-modes

Would you mind sharing more about your specific use case so I can share it with the eng team working on column sorting? :slight_smile:

I think I can share something I was just asked by my client...

I have a table of orders, including customer, supplier, etc.

I am using the group by customer and ideally would like to sort by the count desc, so the customers with the most orders first. (that's my first issue)

then, i'd like to at least sort the children by another column (in this case, supplier)

i see i can sort by supplier, which is helpful, but i don't see the option to remove sorting on column headers anymore and i swear those were on the older table. it looks like removing sorting could be accomplished by removing the column headers, but that's not an option

1 Like

I am using group by rows, and the sort functionality is gone now.

How do I sort by columns when grouping by rows?

We have an outstanding feature request to allow sorting by a column outside of row grouping. I'll reach back out here if I get any updates internally

2 Likes

Thank you!

Any updates?

Sorting table groups by count is still a needed feature, same with custom sorting I suppose

Hi there,

Thanks for chiming in on this feature request.

We are still tracking feedback and +1s for the request to sort grouped rows by column or aggregation outside of grouping. Unfortunately, the issue hasn't been picked up yet, so I don't have a timeline on when this will ship

You can use the setSort API (table1.setSort) to define the table's sort behavior, so I expect that would solve the customization if it was possible to sort grouped data in this way

+1
I also have cases where the text in the "group by" column does not relate to the order I want the groups to be listed.
The order I need is determined by values of columns within each group - typically dates, so groups containing the earliest dates should appear before the ones with later dates.
It's not trivial, because with several rows within each group it's not clear which row to take the sort value from. In my case the logic would be to sort the inner rows first, and then take the group-sort value from the first row in each group.

An example would be an itinerary where a number of days are spent at different locations. The aim is to list the locations as headings (groups) with the daily activities listed within each group (location). Obviously we want the locations listed in the order they are visited, not alphabetically.

Edit: I solved my problem in a better way. In the transformer preparing the data I was able to pick out a "day number" and add a prefix to each location like...
"Day 1-4: location D"
"Day 5: location X"
"Day 6-9: location B"
Then the alphabetic sort gives the right order of the groups and it's actually an improvement to the header to show the day number of the itinerary.

1 Like