Skip to content
This repository has been archived by the owner on Apr 18, 2020. It is now read-only.

Show visual cue when exporting #36

Closed
damien7792 opened this issue Feb 13, 2020 · 2 comments
Closed

Show visual cue when exporting #36

damien7792 opened this issue Feb 13, 2020 · 2 comments

Comments

@damien7792
Copy link

Hi, I'm using TableToExcel to download a table that can be sometimes pretty big, and it takes up to 10-15 seconds for the download to start. I've been tasked with showing some visual cue that the download is preparing. I'm using jQuery.
I've tried to change the style/color of the download icon right before calling TableToExcel, but it seems this change doesn't have time to be reflected on the page before TableToExcel starts processing, because the color changes once the download has finished.
Any idea how I can achieve that?
The only thing working is to display an alert, but ... that's not a great solution.

Thanks
Damien

@rohithb
Copy link
Member

rohithb commented Feb 13, 2020

@damien7792 first of all, it is not a good idea to use TableToExcel for exporting large amount of data. TableToExcel is developed as a workaround to temporarily replace a legacy way of exporting HTML to excel file (till we gradually migrate everything to server side).

TableToExcel is iterating through each td and creating the corresponding cells in excel, so this is a blocking process. The browser will not be able to do anything else(including repainting the DOM) at this time. So it is not advisable to use this to export large amount of data, since it causes an unpleasant user experience.

However, if you want to go forward with this approach, you could try deferring the conversion.

$('#exportBtn').loading(); // to display the loader
setTimeout(function(){
    TableToExcel.convert(document.getElementById("table1"));
}, 0);
$('#exportBtn').resetLoading(); 

Something like this should work.

@damien7792
Copy link
Author

Thanks, it works fine with the delay

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants