Sort a Table using data containing option set(s)

Hello all, The Datatype I’ve used to construct my table with contains several fields that have links to other Datatypes and Option sets.
The problem is: I need to sort the table by the options contained in the set.

The “Sort by:” dropdown on the editor only shows data fields containing txt or #. Any field containing links to other Datatypes or Option sets doesn’t appear.

I have tried using “Change which field…” to pursue various “insert dynamic data” options but nothing seems to work? I can’t believe I’m the only one who’s ever needed to do this?

Has anyone actually done this? I’m out of ideas…

This is one of those Bubble limitations you kind of have to work around.

The simplest way is to store whatever you want to sort by as plain text (or a number) directly on the thing. So if you have an option set field like Status, add another field like Status_sort and save the option set’s display value (or any value you care about for ordering) into that field.

Then sort the repeating group by Status_sort instead.

When Status changes, just update Status_sort in the same workflow. If you want to make it foolproof, you can also enforce it with a DB trigger so any change to the option set automatically updates the stored text.

Not elegant, but it works.

Thanks @code-escapee I was afraid that might be the case. I’ve been resisting the addition of a “sort order” field, figuring I was just overlooking something? Again, thank you for such a quick response and I might just wind up taking your advise.

To filter by datatype/option sets fields you can use plugins like List Shifter (now it is part of the Floppy Plugin).

There are some old threads about this limitation that you can check, like this one.

I will, thanks for sharing!

There’s no need to resist. The extra field doesn’t cost much or change any configuration. And using list shifter for this is overkill…

Sorting limitations of lists is one of the reasons @keith made list shifter. So no it’s not overkill.

What a plugin’s creator originally intended it for isn’t really relevant to whether it’s overkill here.

The actual problem is sorting by a single option set value. Installing a plugin, wiring it up, paying for it, and then dealing with its quirks just to get a basic sort adds a lot of moving parts for very little gain.

Saving the option’s display value or a numeric sort order directly on the thing is boring. That’s the point. It’s simple, predictable, and easy to maintain.

ListShifter makes sense when you need complex, user-driven sorting across multiple fields.

1 Like

I didn’t disagree, I use fields for sorting too. Mostly for serverside processing. But it’s not overkill to use List Shifter to do it clientside. It’s $19 and comes with lots of nifty features and elements.

Not everyone needs to create a new field just for sorting. Chances are that if someone needs sorting for 1 value, they will need to be able to dynamically sort other values that Bubble’s sorting doesn’t support. So why go through the trouble of changing schemas when you can just purchase Floppy to do it clientside?

It’s especially practical if the app has already been fleshed out and schema updates will take too much rework.

There are of course a few other ways to accomplish the same thing but what you suggested still is the easiest if you don’t want to use a plugin.

Great idea. I tried adding a field to sort on but got major errors. For some reason, once I added a new field. I am unable to edit ANY existing record or add new ones. I have a trouble ticket in but no help so far. I had to backout of all the changes I made to get things working again.

I think I will try the plugin route.

What about using the “Group by…” option? That sounds like a great way to handle it…. However after just clicking on group by… I got 47 errors! Has anyone successfully implemented “group by..” in their table? And does grouping by an Option set sound do-able?