Sort repeat group alphabetically by field using a different data type

Under the condition that it is impossible to change the data type, is it possible to sort this repeat group by alphabet? And without using paid plugins.
1



Hi!

In your data source after the search try using :sorted

Don’t work. If I’m doing something wrong please correct me.


Any idea/solution how to fix this sorting? I run into same issue

Unfortunately no. Perhaps with the standard features of the bubble, this cannot be done. The only solution is to add a field to the data type by which it will be sorted, but this is not the solution I wanted to achieve.

1 Like

Hi! Sorry i totally missed your response from a while back.

Your RG data type should be set to Members then you can sort by Name. Just point the data source to search for Family’s Members. You’ll be able to sort within it’s constraints without having to use :sorted

If you want to specify which family to search for , you can grab from whichever element or input is already pointing to that family.

Sorry, I don’t quite understand how to do this.
My example is a simplified version of a larger problem. For example, there is a store and there are several types of goods in it, each of which is in a separate data type: Stationery (name, price, etc.), Furniture (name, price, etc.), Electrical engineering (name, price, etc.) and so on. I want to combine them all into one data type All products. And then create RG with the content type All products and sort by the name or price of each product, but as I understand it, this is not possible if in the data type All products does not add text fields by which the RG will be sorted.
In my task, the content type should be Family, but then it does not give sorting by name or surname since it sees Member as different data type and not text .
There exemple and I turned on editing for everyone, if you know the answer to my question please show me My-test-app-everyone | Bubble Editor

Ah okay! I’m on mobile and haven’t gone through ur app but i understand your needs better.

What i do for similar situations is something like this:

. Create a state for list of text, lets call it “ProductList ByPrice” as a sample

. Set the state, for example during page load, to Do a Search for each product type but formatted to text like this “price|productType|productUniqueID” delimited by “}”. Which will then be :split by “}” to bring it back to a list of text.

In the formatted text, “productType” will be a name you will use to refer to a particular type.

Then let’s say you have 3 product types, do a :merge with to collate each Do a Search of each product type.

. Now you will have a list of text that all start with price.

. In the RG of products set you Data Type to text and Data Source to the state “ProductList ByPrice” and you can use a :sorted “Yes” or “No” (whichever you need)

. In that RG’s cell, just create groups for each product type, set it’s Data Type to a product type then set it’s Data Source as “This Cell’s text:split by ‘|’ :last item”. Lastly set a condition "This Cell’s text:split by ‘|’ :item#2 is product type.

“Last item” will refer to the product’s UniqueID in “price|productType|productUniqueID” and item#2 refers to productType

It takes a while to get used to it but I use this method a lot.

But to be honest it would be better to rethink your Database and have a Data Type like Product which links to your different product types and stores prices. It will make things alot easier in the future!

2 Likes

Wow, quite an interesting way to combine different data types into one RG.
As far as I understand, it is impossible to sort the RG by the data type fields located in another data type. Yes, in this case it is better to plan the structure of the data base in advance.
I will leave the question open for a while, maybe there is another way to sort directly, but it seems to me not. While your answer seems to me the only solution =)

PS: I did not understand this moment: "In that RG’s cell, just create groups for each product type, set it’s Data Type to a product type then set it’s Data Source as “This Cell’s text:split by ‘|’ :last item”. Lastly set a condition “This Cell’s text:split by ‘|’ :item#2 is product type.”
In group i set the data source to search for an item by ip = Current cell text:split by ‘|’ :item #3
It works, but I don’t quite understand how to do it the way you describe.

Hi!

Sorry i should have elaborated better.

Setting the Data Source to “This Cell’s text:split by ‘|’ :last item” and “This Cell’s text:split by ‘|’ :item#2” will refer to the individual parts of the text when split by the delimiter “|”.

How “:split by” works is like this.

Sample Text
price|productType|productUniqueID

When we add " :split by | " it will break the text into a list of text arranged by order of the text:

#1: price
#2: productType
#3: productUniqueID

So by appending with either “:item#”, “:first item”, “:last item” we are referencing the index of that list of text.

Sorry i forgot to add that this condition should be set to make that group visible if the condition is true. So make sure to uncheck show on page load.

Since we only want the group (which is holding information of a specific product type) to show for that specific product and not show any other groups for the other product types.

What this does is to grab the productUniqueID from the cell’s text (which looks like the sample text above) then match the product’s UniqueID and hence any elements in the group can now access info from that Product in the database. We won’t have to worry about the product Type since any visible group has already matched in the conditional.

I’m experimenting with my first example, but you say that the data source of the current cell group is “This Cell’s text:split by ‘|’ :last item”, but it doesn’t work for me.



If I use “Do a search for” then it works.

According to your description, it seemed to me that you can somehow do it without searching. Or did I misunderstand?

My bad again! You doing it right, you must use “This Cell’s text:split by ‘|’ :last item” as a constraint in your Do a Search.

Glad it’s working for you!

1 Like