HalitTalha / ng-material-extensions

Extended features for @angular/material components
Apache License 2.0
101 stars 52 forks source link

exportCompleted triggers before export is actually complete #41

Open annmarie-switzer opened 4 years ago

annmarie-switzer commented 4 years ago

Any code within exportCompleted() seems to be triggered before the export is actually complete.

https://stackblitz.com/edit/mte-demo-ohmwfn

Expected Behavior based on the linked example: The birth column should not get exported, and should be added back to the template after the export report has been completed.

Actual Behavior based on the linked example The birth column is removed but is immediately added back again before the export is generated and downloaded.

You can see this is the case by commenting out the code inside exportCompleted() .

I realize that this particular example is not useful IRL since I could just use the hiddenColumns attribute. What I am really trying to do is use this functionality on a table with expandable rows. I want to remove the expanded content from being exported, then add it back to the template after the export is completed. I tried to make a Stackblitz showing this exactly but I was getting an error.

Also, I don't know if this is an issue with the library or with Windows, but it seems like when I export to CSV, the file name changes but the content is the same. If I export as CSV, then make a change to the code, then export again, the expected change does not show. I have to delete the file from my downlaods folder and export again in order to see the expected result. Im using Windows 10, Chrome 80. I tested a little with the other file formats and they seem to work as expected.

HalitTalha commented 4 years ago

Thanks for reporting. I'll look into your case with column hiding. I couldnt understand the second issue you mentioned though. Could you please elaborate?

annmarie-switzer commented 4 years ago

Sorry for being unclear. I have done a little more testing. The exact problem seems to be a delay in what data is being submitted to the .csv export files. If I comment out the exportCompleted() code, I expect the .csv file to not show the birth column. However, the first export file will still show the birth column. If I immediately click the export button a second time, then the birth column is gone in the file as expected. This does not seem to be a problem with .json exports, so I wonder if it is a bug with just .csv exporting. I am on Windows using Chrome.