Move items in RG

Okey so, how hard can it be?
I have learned alot using bubble for some years now but I am still not able to have simple items in a simple repeating group simply able to be reordered and saving the new order. This is a fundamental and basic function in every app today and still it is so hard to do in bubble. If someone has figured out this please help, also I have tried plugins and they dont work logically. Here is what I have (rebuilt over 20 times just for this purpose), a simple list of words sorted by its id and I want to manually sort them in the repeating group and saving this sorting in the db. See image thanks

Have you tried using the List Shifter plugin? Not done this exact thing with it but think it can easily do this. There’s various videos on how to use it here List Shifter: Reverse, Rotate, Swap and ITERATE (Loop) Over Bubble Lists | Now at v1.4: Adds Numeric Option, GET INDEX Action from the author @keith

Hi there! Thank you but I only found two videos by keith and another video from another guy about some complicated iteration kinda thing for calculating some pi circles and I didn’t understand half of it. I really couldn’t find any useful help about this shifter plugin when it comes to my problem. Probably is a great plugin for other stuff. I appreciate your help Wright but do you have any other solution for moving items in a repeating group? Thanks and have a great day

Oh nevermind, I found that thread you linked. This is way too complicated and big just for doing a simple thing I am trying to do… But thanks anyways, have a good one

Hi @andersenrichard86,

Can you explain how the UI is supposed to work? It looks as though the user can only bump items up (but not down) one slot at a time using the up arrow. Is that correct?

If so, and assuming the RG will always display all items to be rearranged, then it should be straightforward. You’ll likely need a numeric “position” field on the RG Thing. When the up arrow is clicked, just update that field value for the Thing being moved as well as the Thing above it - i.e. essentially swap position values. The RG should automatically re-sort to reflect the change. This approach would update the DB with each move.

No this arrow is just


this, see image

Thanks yes I have tried arrows too and i tried just having them to swap numbers but I never got it to work. Everything was very fiddly and prone to breaking. I also want to be able to delete thing and add new notes

You could try the method that works with the drag and drop plugin to reorder lists. I’ll use the example of an “up” arrow to move an item up one spot. This thing has a field called OrderNumber which is how it’s sorted. (That’s what’s in the parenthesis.)

A (1)
B (2)
C (3)

This next part is referring to their OrderNumbers. To move C up one spot, between A and B do this.
Workflow when C’s up button is pushed:
Step 1: B’s OrderNumber-A’sOrderNumber/2 = result (in a number state)
Step 2: result+A’s OrderNumber = new OrderNumber of C (Update this second part in the database).

That workflow would reorder the list in real time as long as its sorted by the OrderNumber. That might be one way to move items up and down on a repeating group list.

Yes, I wanted the dragged item to swap its ID with the one it’s dropped on, but I have failed this every time so I gave up. I have looked everywhere for a simple formula or video on how to get this to work but I don’t think there is any out there yet. If you know of a youtube video or a place to find a simple how-to on this I would really appreciate it! thanks

Check this solution: Solved-with-bubble | Bubble Editor

It swaps position values when you move an item up or down. New items are added to the end of the list.

1 Like

You got a great thing going here! I see how you made it search for the item in front (up/down) of the number you are moving and then make the +1 or -1 swap! thanks this is a great idea and I now know how to do that :smiley: would this be doable with bubble’s drag and drop? thanks

1 Like

Happy to help! I’m not sure about the drag/drop plugin.

Great solution, thanks!

I’m just having trouble reordering the RG items when deleting.

Ex:

A (1)
B (2)
C (3)
D (4)
E (5)

When deleting Step C, Step D must assume order 3 and Step E must assume order 4.

I’m trying to use the search function, but having trouble to finding the RG items below the deleted position to adjust the order.

Any idea? Thanks.

Create a custom state of type number in the RG or anywhere you want to store the order of the deleted cell.

In the deletion WF, before deleting the cell, in the first step, store its order in the created state, then, in the second step, delete the cell and finally, in the third step, do a search (Do a search for…) by data type, and use the constraint that selects all cells where the order is equal to the stored order + 1, then reduce (-1) them.

Depending on the number of items in the list, it would be more advisable to use a Backend WF.

Thanks for reply.

I solved it as follows:

WF Step 1:

WF Step 2:

I had to create two conditionals “only when” for cases where the last step is the “last item” (created last in the database), and cases where the last step is not the last item (when I reorder a previously created step to the end of the list).

Works fine.

1 Like

Hi, I was also looking for a similar solution, so that when I delete a record with some “sequence number”, the list moves up one position. I made a custom state with a numeric type, where I write the sequence number of the record to be deleted with an action (before the delete action). Important: It is desirable that the custom state is placed in a group, higher in level of the group or item from which the record is deleted. After that, I simply “lookup” all records in the repeating group list whose “sequence number” is greater than the value stored in the current session in the custom state field and decrease their value by “1”.

That is, for example, in the list of records with numbers 1,2,3,4,5 I want to delete number 3. Then this number in workflow action is saved to the custom state, and numbers 4 and 5 are reduced by “1”. At the same time numbers 1 and 2 are not changed, because they do not fall under the select condition.

I would be glad if this helps anyone else)