Automatically have first row in table selected on page load

I am wanting the first row in my table to be selected with the page loads as I have subsequent tables filtered on that table's selected row.. Since that row is not selected, it causes confusion with the user as no data is rendered in subsequent tables.

I tried using the table setting Default Row, Index: 0 but it doesn't not appear to work.

I found this post, where a suggested workaround is to add a success handler of the table's query to select the row of index: 0 with a debounce delay value. I am surprised this type of workaround would be needed for a behavior that seems like it should be native.

1 Like

Hello @isaacjm,

You may prefer this retool community forum Getting Row Focus on a Table

Its OK, I have solved the problem.

I have just posted my solution on the Retool Community Site.

Mike

Hi @mdsmith1 - thanks for sharing your findings! Your suggestion is working, but might be an unintentional outcome of removing the Primary Key. I would guess the Retool framework team would not advise leaving Primary Key blank as it is an important field for other functionality... would like to hear from Retool team on if this is a confirmed bug or if there is an advised solution.

1 Like

Issac:

I used to use the Legacy Table and did not have these problems.

I had to do 2 work arounds to get a row to highlight when the table came up.

I consider this a bug.

I have also had to add special code to get the selected row to color up properly. If I use the tools, then red (Accent color) becomes pink.

I consider this a bug as well.

Mike

Hello @isaacjm,

Apologies for the issue. We have an open bug ticket to have some engineer attention on this to fix it.

What type of data source are you using? I haven't been able to reproduce this behavior, if you can share a video of the row selection not working on page load that would be very helpful for reproducing and fixing this!

I found that on my end either running a JS Query on page load and calling table1.selectRow() worked as well as setting the default index from the table's inspector panel worked for me as well.

Hi @Jack_T,

Here is a screen recording on google drive:

My resource query is for a Postgres db and my Retool version is 3.131.0
image