Download selected tables all-in-one

Hello,
I have a container tab with a different table for each tab. Currently the user can download each table one by one by clicking the download button at the bottom corner. However, I'd like to provide a way for the user to download a selection of table all at the same time so that he doesn't have to click on each table 1 by 1.
I have a multi-select component to select the desired tables and then next to it I have a button labeled 'download'. I just don't know how I can configure the button to download all selected tables (in CSV format).
Thanks!

Hi, welcome to the forums

There's a couple of ideas that come to my mind - tables have a function that you can trigger called exportData, which afaik does the same as the button on the table footer. You could call that multiple times from a javascript query and that might do what you're after.
The other alternative would be to use utils.downloadFile to put all the data into one large data set and then download that. This ould be a lot more work though, I imagine.

1 Like

Hello dcartlidge, thank you for the answer,
Indeed that would be an ideal option. However I am not sure how to use the js query, is it possible to loop through only the selected items?

yes, you can definitely do that. something like this;

let picks = multiselect1.value; // our multiselect picker
picks.forEach(picked => {
  if(picked === 'one') {
// the user has chosen an option from the multiselect that has a value of "one"
    table1.exportData({fileName:'table_1',fileType:'csv'});
  }
// repeat for other tables
});
1 Like