Access element in other Repeating Group cells

Hi,

I have a RG with a list of Users. In each cell (containing a User) there is a Group element loading another Thing (in my case a Car). Now, in each User RG cell, I need to access the Car Thing/Group that is in the prior User RG cell. I.e. the second cell in the User RG need to access the Car Thing in the first User RG cell.

Is this possible?

Cheers,
Peter

Hi Peter :slight_smile: One way would be to place a transparent input in the cell (of type: integer), and set its initial content to be (Current Cell’s Index-1):

Then the data source of the Car Group in the cell would be: “Repeating Group List of Users :item# Transparent Input’s value’s Car”:

The only other thing that may be needed is to place a conditional statement on the Car group which changes its data source to be something else for the first cell (since cell 0 doesn’t exist). For example, the conditional statement could be:

When the Current cell is 1 →
Data source: Repeating Group List of Users :item# (Repeating Group List of Users:count)'s Car:

That would show the last User’s Car in the first User’s cell. I think that should work, but let me know if not! :slight_smile:

2 Likes

Hi Faye!

I’m with you. Wow! U know your way around Bubble! :slight_smile:

However, my Users don’t know which Car they have before the RG is loaded. So I need to either to be able to:

  • access the Group element of the previous cell or,
  • be able to run a workflow when each cell is loaded to update the Users Car field with the car, and then use your solution.

What I’m trying to do here is to create a linked list of Cars, making it easy to insert, remove and change place of Car in the list. I’ve earlier used a field for an ordinal position but that is cumbersome when inserting/deleting/changing place of a Car in the list.

The User thing is just a dummy thing used to create a long RG that I can populate with Cars in the order determined by the linked list.

@fayewatson do you have a link for this example, I need some hands on to fully understand, thanks

Hi @info_ptmx Sure thing! :slight_smile: Here is the editor:

@philledille Ohh! I think I understand! :slight_smile: Just want to double-check:

  1. You are creating a list of cars and need to change the order so all of them reposition correctly in the list, and you don’t want to do this by setting an Order field on the Car type?
  1. The cars are not related to the User object, it’s just for showing the Cars currently?
  1. Yes!
  2. Yes!

:slight_smile: !

@philledille So sorry for the delay! Is this along the lines of what you’re trying to set up? :slight_smile:

Preview:

Editor:

In this example, I created two types: “CarOrder” (instead of using User) and “Car”. The “CarOrder” type is what holds the number of ‘rows’, and Cars can be moved in and out of the rows (without deleting that space in the list):

Then you can drag and drop the Cars from the right side, into the CarOrder cells on the left (as well as add Cars or CarOrder rows):

Right now I don’t have drag and drop set up for the cells on the left yet. Do you need that or do you need it so you can move Cars up or down with buttons instead? :slight_smile:

1 Like

This is really neat! Now I learned about drag’n’drop as well ! Thnx!

Late reply because I’ve been thinking alot on how to take it further and allow an insert of a CarOrder row in between two existing rows. But I can’t solve it.

So I tried another idea instead of a list for containing (CarOrders) the Cars. Instead I try with a decimal order number. This seems to work. What do you think?

Preview:

Editor:

@philledille No problem at all! :slight_smile: The up/down buttons approach you have is probably better for capacity reasons! Just incase you’d prefer drag and drop, I duplicated my previous demo and modified it so its only drag and drop:
Preview:

Editor:

In this example, both repeating groups display CarOrders (to make the drag/drop process more simple) and the CarOrders on the left-side can be dragged and dropped between cells:

This happens because of this workflow:


This looks complicated, but it is just telling Bubble, “When any of the Drop Area Listed CarOrder elements (found in each cell of the left-side repeating group) have any CarOrder Group dropped on it” → do the following:


  1. This changes the “Current Workflow CarOrder”'s Order field to be the Order of the cell where it was just dropped. (The “Current Workflow CarOrder” refers to the Droppable CarOrder group that was just dropped)


  2. This second action adds 1 to all of the CarOrders’ Order fields, that are beneath the Current Workflow CarOrder. This makes sure those CarOrders ‘move down’ to make room for the CarOrder that was just dropped, and keep everything in order.


  3. This third action subtracts 1 from all of the CarOrders’ Order fields, that are above the Current Workflow CarOrder. This makes sure that those CarOrders ‘move up’ to make room for the CarOrder that was just dropped, and keep everything in order.

Aside from dragging and dropping between cells, those “CarOrders” can then be removed, or ‘dragged-out’ of the left-side list to the right-side list of CarOrders:

This happens because there is a DropArea on the right side as well, and when a Draggable CarOrder group is dropped on it, the workflow sets that just-dropped CarOrder’s Order field to empty.


Since that CarOrder’s order field is now empty, it is shown in the right-side repeating group only:

And the right-side Cars can be moved to the left by dragging them between those cells as well:

Since both repeating groups are of type “CarOrder” now, the CarOrders on the right can be dragged between CarOrder cells on the left, all using the same original re-order workflow:

The reason it’s probably not the best idea for large lists is because it uses two ‘Make Changes to a List of CarOrders’ each time something is dragged between cells. This is needed to make sure the cells above the just-dropped cell move upwards by 1, and the cells beneath the just-dropped cell move downwards by 1 (If anyone knows of a different way, please let me know! :slight_smile: )

Dividing by 2 for drag and drop sometimes works, but it can also cause a few cells to have the same Order number which makes things look like the drag and drop doesn’t work.

Here is a more in-depth explanation of the drag-and-drop workflows I used for this example but feel free to let me know if you have any questions setting it up :slight_smile:

4 Likes

A ton of thanks for all your insight and effort! :sunny:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.