Call buttons in a column from a single button

I have created a table with a custom column which consists of button. Each button triggers a query and downloads a .csv file.
I want to create a button ("Export All") which clicks all the buttons in that column in the table. This will I will be able to download multiple .csv files. How can I do this?

Thanks!

Hi there!

It sounds like this would be a separate button component, that triggers a JS query which runs the same kind of query those custom column buttons run normally individually.

Would you be able to share a screenshot of what that query looks like? I’m guessing it might already use an i variable that is passed in from the table row. If so we could pretty neatly build a simple JS query like this to run that query for all rows:

tableName.data.forEach((row,i)=>{
targetQuery.trigger({
additionalScope: {"i":i}
})
}

I came across this post while looking for help trying to do this exact same thing. I had written something that’s very close to what you suggested, Alex, but no matter what I try (promises, async/await, even simple delays with setTimeout), I can only get a single file to download (most of the time).

The loop is working fine, as I see all download URLs recorded via console.log, but the browser only prompts to save the first file.

If it matters, I’m using utils.openUrl to retrieve files from signed S3 URLs. I’ve tried both opening in same page and new page, with same result… I can only get the first file to download most of the time.

I believe this is a timing issue, because when I’m in edit mode and Retool prompts that I might lose saved changes when leaving the page, I correctly get all of the download prompts for all of the files. But without those delays, I just get the first file.

I’d appreciate any pointers on how to resolve this issue.

So to clarify, you are opening all of the signed S3 urls in new tabs to download them? Would you mind sharing a screenshot of that JS query?

I think you would need to run a GET generic REST Query to the signed URL, which will return a base64 encoded file from that url. Then the onSuccess argument of that .trigger() method would run utils.downloadFile() to download the return from that REST query.

The “Read a file” action type in the S3 integration will do the same thing (read a file as base64 into the app), or the “Download a file” action will directly initiate the download, but both of them take the s3 key as an input and run the request through your resource setup rather than a signed url