So I currently have a table in retool with primary key ID that has row selection set to multiple. One of the things I want to do is keep the multiple row selection enabled but I want to allow a user to upload a csv file with a ID column and the table will parse the IDs from the csv file and select the rows that have the corresponding IDs.
Ex
retool table
ID other columns with information
1
2
3
4
5
6
csv
ID
2
4
6
output: after uploading csv file the table will select the records with ID 2,4,6.
After the csv file selects the IDs that were present, a user can continue selecting records if needed.
the csv file I am testing with will have ID as the first column but I need help figuring out how to implement the row selection through the csv file.
Use one of the file components to upload the file, convert the base64 to string, parse the csv to json, gather the ids into a list, and use table1.selectRow(). You will also need to set the primary key property on the table component to your ID field.
I am very new to retool and more of a visual learner. I will try to implement your solution but if you can simulate that it on a dummy table of your own that will be very helpful for me.
@matth So when I ran your js it does work only when the file type is a csv file. So I tried parsing an excel file and I was receiving errors. I took the IDs from the excel file and placed them in the csv file and it was able to do the selects accordingly. I think there is an issue when trying to parse an excel file.
It looks like parsedValue is slightly different when excel is parsed; there's support for sheets. You'll have to handle that in your js query if you want to support both excel and csv