cordova Posted February 2, 2022 Report Share Posted February 2, 2022 Hi, So I have an HTML DataPage wherein I embedded multiple Report DataPages as iFrames. Would it be possible for me to have a button in the HTML DataPage that activates all the Download Data link for each of the Report DataPages so that all of them are 'clicked' all at once then generates the documents all at once? This way I wouldnt have to download them individually. Quote Link to comment Share on other sites More sharing options...
futurist Posted February 2, 2022 Report Share Posted February 2, 2022 Hi, you could achieve this with JavaScript. You create a function for your button's onClick event. So in your body, you create the button like so: <button onclick="myFunction()">Print all</button> Then for the actual script: <script> function myFunction() { const iframez = document.getElementsByTagName("iframe"); Array.from(iframez).forEach(function(elt, i){ var downloadData= elt.contentWindow.document.getElementsByClassName("cbResultSetDownloadLink"); downloadData[0].click(); }) } </script> What this does is it collates all of the "Download Data" link on each of the Report DataPage and then 'clicks' each of them, therefore downloading the report. If your Report DataPage allows download of only one specific type of file (i.e. only Excel), it automatically downloads that file. But if you enable multiple file types (PDF, Excel), then you will see the dropdown which allows you to choose the file type, then proceeds with the download. Note that you would have to wait for all the iFrames to load to be able to download all of their reports. Lepidoptera 1 Quote Link to comment Share on other sites More sharing options...
futurist Posted February 2, 2022 Report Share Posted February 2, 2022 In additional to my last response, you can also add a code that enables the button ONLY when all the iFrames have loaded. On your button, add an ID and add the 'disabled' attribute: <button id="printall" disabled onclick="myFunction()">Print all</button> By default, the button will then be disabled. Then, at the beginning of your script, add: window.addEventListener("load", function(){ document.getElementById('printall').disabled = false; }); What this does is, once the page has loaded completely (including the iFrames), the button will then be enabled. This is optional. Interface-wise, there's no harm when a user clicks on the Print All button even though the iFrames have not loaded completely, but you could apply this so that there won't be a fuss about a report not being downloaded, or the button not working, when in reality, the iFrames haven't loaded yet, hence why the report is not generated. Hopefully that makes sense! Quote Link to comment Share on other sites More sharing options...
Mushigee2266 Posted November 14, 2023 Report Share Posted November 14, 2023 Thank you it is working. Is it possible that all downlaod files downloaded in one zip folder. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.