I have a Retool DB query that after updating a table, runs a script as a success handler. The script captures the primary key (user_id) of the currently selected row, then refreshes the table to display the updated data. After refresh, I need the same row to remain selected, so I use the table.selectRow() function with the previously captured primary key to select the desired row.
This is all working. Unfortunately though, the selected row is no longer in view, so I've tried various methods to force it into view, with no success. I've tried:
Welcome to the forum!
Saying the row is no longer in view, are you paginating the table on the front end? Are you storing the row id or some other value like index in a temp variable?
Is the table growing in size? Is it sorted alphabetically?
Hi. @ScottR, thanks for responding! On the front-end, my table is not paginated, just scrolling. I'm not using any temp variable, although now that you mention it, that's probably the better way to go here. I'm resetting the filter as part of the success handler, which is making the table grow in size. It's sorted alphabetically.
It's working! Your questions and insights led me to the solution, so thank you!
What finally made it work was separating the selectRow and scrollToRow in a separate JS query and trigger the query from the success handler. I'm not sure why that was the trick, but I'm assuming it has to do with the timing of when everything is triggered.
I ended up not needing the variable at all in this case, but it proved useful in another task I was stumped on, so I'm glad you suggested it.
Here's the code that's working for me for any others with this issue: