Need to put the row index into localStorage

I need to capture the index of a row and put it in to localStorage.

The native term is "table1.selectedRowIndex";

I have been working with Claude for an hour and have gotten nowhere.

Any thoughts?

Mike

Hi Mike,

Thanks for reaching out! Could you share a screenshot of the error message that you are seeing or alternatively paste the message directly here (please ensure there’s no private information).

Best,
Jordan

Claude AI finally found a solution to this. Claude tried to use a number of Java Script solutions involving Utilities which Retool did not recognize.
The working solution is:

const R1 = table1.selectedRowKey;
console.log(`Here is R1: ${R1}`);
variable1.setValue(R1);
localStorage.setValue("mR1", R1);
console.log(`R1 stored: ${R1}`);

You have to bring in a variable (in this case called variable1) from components to get this to work.

This puts a value of mR1 in localStorage equal to R1 which is the index of the selected row.

Mike

1 Like

Hi Mike, I’m glad you found a solution to your issue. I believe localStorage.setValue("mR1", table1.selectedDataIndex); should work as well without requiring the additional variable.

Kind regards,
Jordan

Jordan:

Thank you for your reply. I will try that out and get back to you.

Mike

1 Like

Jordan:
Your point was good.
I tried it without the variable1 line and it worked fine.
I will mark your answer as the solution.
Mike

1 Like

Thanks for getting back to me Mike, glad that alternative solution works well for you.

Best,

Jordan