Unable to Access Selected Row Within Repeatable

  • Goal:

I am trying to delete a member within a repeatable view with a row action but, the table within the repeatable is not returning anything.

  • Steps:

I have tried using both table2 and table2[i] as run script within the row action.

deleteEmployeeFromProject.trigger({
  additionalScope: {
    employeeId: table2.selectedSourceRow.id,
    projectId: i
  },
    onSuccess: function() {
       getAllProjectMembers.trigger();
    }
});
deleteEmployeeFromProject.trigger({
  additionalScope: {
    employeeId: table2[i].selectedSourceRow.id,
    projectId: i
  },
    onSuccess: function() {
       getAllProjectMembers.trigger();
    }
});
  • Details:

I'm using the cloud version of retool.

  • Screenshots:

NOTE: Data in table removed due to confidentiality

Hi @lpearl, on your script, try changing the value of projectId to table2.selectedDataIndex

I'm doing some testing on my end and it seems like a bug with using the index of the repeatable on a script for a table nested within a List View.

Here are my findings:

However, when we use selectedDataIndex, the index is sent as expected.

2 Likes

It looks like what we need is the index of the repeatable, not the row on the table.

We'll need a State variable and 2 scripts:

  1. The State variable will hold the id of the repeatable. Every time we click on a row, we update the value to the new i:

  2. The second script will trigger the query and we'll use the value of the variable to pass the index of the repeatable. However, this one needs a 'Debounce' of 100ms to wait for the variable to update, we can probably use less but 100ms won't be noticeable and it's a nice cushion:

Note: We don't need to use await because of the debounce so feel free to remove it on your end. I tried doing them on the same script using await but the query seems to be using the cached value of the variable. The value of index was always one step behind.

1 Like

Hi @Paulo,

Thanks, this solved my issue!

You are welcome! Happy building. :hammer_and_pick: