Update List - Set Field = OWN Cell Index

Thanks for looking. First my question, but then an explanation of what I’m trying to achieve, as there may be a better method…

The set up is as follows:

  • Repeating Group
  • ‘Position’ Field

How do I make it so that when a button (inside a cell) is clicked, that each record in the repeating group has the Position field updated to = it’s own Cell Index?

So far I’ve only been able to Update the List of Things so that every record’s Position is updated to equal the value of the Current Cell’s Index (i.e. the cell where the button was clicked). This means they all end up with the same Position value.

IS THERE A BETTER WAY TO DO THIS

What I’m actually trying to do is let users add a finite number of items (10) to a list. These are displayed in a repeating group. I then want the user to be able to sort them.

I wouldn’t have a clue how to do it drag/drop, so each cell has a move up/down arrow.

Some of the challenges are:

  • New items should be added to the bottom of the list (so what should the initial value of Position be set to?)
  • If the user clicks ‘move down’ and I was able to set all records to have the Position updated to their own current cell index, then it would be easy to include in the workflow an instruction to set the current cell Position to be Current Cell Index +1 … but how do I update (find) the next cell to it’s position is it’s Current Cell Index -1?

Thank you again for your ideas.

Searching through the forums I found this suggestion - which is the best I’ve seen so far. Thought I’d link to it for your convenience. If there are other suggestions, I’d love to hear them.

2 Likes

I’ve been racking my brain with the same issue. This would open up many possibilities if we could set a field for EACH thing of a repeating group equal to it’s index in that repeating group!

1 Like

Since, I wasn’t able to find a quick solution for setting a proper position by index in combination with draggable elements and failed miserably with ListShifter Pro, especially since I cannot rely on updates from Bubble changes in the db (sorry @keith :man_facepalming:, but I plan to use the Floppy license for Bulky), I came up with a quite neat solution.

My Setup:

  • my datatype has a “position” attribute (which should be an integer because we want to evaluate the usage by position and starting with decimals will undermine that idea
  • the droparea uses datatype “number” and sets it to the middle value between previous and next “position”, e.g., item 1 has position 1 and item 2 has position to, so the droparea on item 2 has value 1.5
  • when I drop a draggable on the droparea, I set the position of the droppable object to the one from the droparea
  • I make a “change on list” step, based on the same datatype and the repeating group and now the magic happens:
    ** I do the same query as in the repating group, searching for my datatype with the condition "position <= This elements’position and then use the count of that query

I know, it’s been 7.5y since the post has been created but I hope my solution is still helpful for some of you.

Kind regards.