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.
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:
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.
@philledille So sorry for the delay! Is this along the lines of what you’re trying to set up?
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):
@philledille No problem at all! 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:
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 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:
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)
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.
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:
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! )
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