Get the indexes of a re-orderable list

Hi there!

I am creating an application, where my users can prioritize (rank) their preferences based on their personal opinion (not based on a metric). I chose the reorderable list to achieve that but I can't find how to store in my database the final sort(position) of the values.

Could you help me?

Welcome to the forum!

Can you share more information?
Screenshots and perhaps what the sort order looks like before and after sorting... are you iterating through the order or bulk updating/inserting?

Hi Scott thanks for your immediate response!
The user has to rank the following choices (they will be more in the future) based on his belief about their priority.

With the submit button, the query behind should update the Big Query table and fill the ranking column with the position of the element on the final list.
For example, with the above order, the table should look like this:

The query that I have written until now is the following, but I can't retrieve the position of the reordable list.

Do you have any ideas on how I should proceed? Maybe a different component (of the reordable list) is more suitable for this use case.
Thanks a lot in advance!

Why not put the information into a table and then edit the cells to change the order and use a changeSetArray? I am not familiar enough with BQ to really dig into this at the moment....


I can't tell from your screenshot, but are you running your query in a loop?

I don't have a BQ resource to test against, but this is how I would try it in the Retool DB.

First, create a transformer to structure data from the reorderableList into objects with the data you need for your table, so it includes ranking and name.

return {{reorderableList1.value}}.map((val, i) => {
  return { name: val, ranking: i+1 }

This will leave you with an array that looks like this:

  { name: 'first item in list', ranking: 1},
  { name: 'second item in list', ranking: 2},
  { name: 'third item in list', ranking: 3}

The transformer works off the index of each item and adds 1, if you'd prefer the zero-based index, just remove the +1 in the transformer.

Next, switch your DB Function to GUI mode and set it up something like this:

Change the table to be your seo-word-clusters.retool.clusters table. The data in the transformer should work if you've just need to update the ranking column value and the name is unique.


@MikeCB This is exactly what I need! I am not familiar with javascript, but I implemented it exactly the way you described and worked! Thanks a lot for your help.

1 Like