HalitTalha / ng-material-extensions

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

Expandable rows data being exported even with hiddenColumns #55

Open ghost opened 4 years ago

ghost commented 4 years ago

Hello, if you have a table with a table inside the expandable row it will get exported along the [0] column. That means that if in the main table uses [hiddenColumns]='[0]' it will hide both the column 0 and the expandable row containing the mat table.

To make it clear, the structure is: Mat Table (main) |-->column 0 |-->column 1 |-->column 2 |-->column 3 |-->expandable column definition -----|-->Mat-table (inside the expandable row) ----------|-->column 0 ----------|-->column 1

HalitTalha commented 4 years ago

Hello @MatiasProietti, thanks for reporting the issue, by any chance could you provide a stackblitz of what you are experiencing?

ghost commented 4 years ago

Hello! Thank you for answering so fast, here is a demo code that you can use. It doesn't have a table inside a table but still the bug is there: Export expandable rows bug. Everything seems to be fine but if you remove the [hiddenColumns]="[0]" you will get not only the column 0 but the expandable row data as well. Also with [hiddenColumns]="[0]" you get blank rows between each data row in the exported file.

HalitTalha commented 4 years ago

Hi again, although what you have demonstrated seems a buggy output it is actually an expected behavior. You are rendering an extra row for each row of your table which is the expandableness implementation. That row has one column and its column index is of course zero. That's why [hiddenColumns]="[0]" is hiding it but since the expandable row is being rendered it ends up as a blank row in the exported file. For now the easiest workaround to this could be unrendering the expandable row right before exporting the file and rendering it again when the export completed. However there could be a bug with exportComplete event #41. If you will use it you should use it by setting a timeout. I will label this as a feature request to look into it properly in a future release.

stnor commented 3 years ago

+1 I would also like to have the empty rows removed in the exported file when using expandableRows.