Exporting Master-Detail Grid to PDF

1 Answer 161 Views
Grid PDF Export
Arnþór
Top achievements
Rank 1
Arnþór asked on 13 Jun 2022, 07:09 PM

Hi,

Is it possible to export a master-detail grid to PDF? I've been able to do it in excel with your examples but haven't figured out how to do it with PDF.
Also when is pdfExport event emitted? I'm calling grid.saveAsPDF() but the event doesn't seem to be emitted.

Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Hetali
Telerik team
answered on 13 Jun 2022, 08:17 PM | edited on 15 Jun 2022, 05:31 PM

Hello Arnþór,

The PDF Export of the Kendo UI Master-Detail Grid is not supported as mentioned in the known limitations. However, by expanding all the rows of the Master-Detail Grid, the Grid can be exported to PDF using the Kendo UI PDF Export component. The following custom function can help you achieve that:

public pdfExport(pdf) {
  this.products.forEach((item) => {
    this.arr.push(item['ProductID']);
  });
  this.expandedDetailKeys = this.arr;
  setTimeout(() => pdf.saveAs('ExpandedGrid.pdf')); 
}  

In this StackBlitz example, I have expanded all the rows and exported the Master-Detail Grid to the PDF. Please note that the large data set of the Grid can cause performance issues and out-of-memory errors.

Additionally, the pdfExport event is only emitted when you click on the PDFCommandDirective button and not with saveAsPDF method as seen in this StackBlitz example.

I hope this information helps. Please let me know if I can further assist you.

Regards,
Hetali
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Arnþór
Top achievements
Rank 1
commented on 13 Jun 2022, 08:39 PM

Thanks for the quick reply that's good to know! Is it on the roadmap to add this feature?

Maybe the wording in known limitations might be improved to mention master-detail to eliminate confusion?

Regarding the event I would have assumed that excelExport and pdfExport would be emitted in a similar fashion  and it seems that excelExport is emitted when grid.saveAsExcel() is called.

Since the PDF is a drawing I guess you could solve this by expanding all the rows of the grid before calling grid.saveAsPDF() is that assumption correct and if so is there an easy way to expand all rows?

Best,
Arnþór

Hetali
Telerik team
commented on 15 Jun 2022, 05:33 PM

Hi Arnþór,

The PDF Export of the Master-Detail Grid is not on the roadmap as it is a limitation.
We are currently working on the Angular documentation, and I have let the team know to modify the limitation content to be more specific.

The excelExport event is emitted when the saveAsExcvel method is called so that the developer can customize the workbook of the ExcelExportEvent before exporting the file. In case of the pdfExport event, the developer can only prevent exporting the file by using the preventDefault method of the PDFExportEvent. This prevention can also be accomplished without the need of handling the pdfExport event, which is why is not fired during the saveAsPDF method.

Please take a look at the modified answer to export the Master-Detail Grid in PDF after expanding all the rows.

Let me know if you have any further questions.

Regards,
Hetali
Progress Telerik

Tags
Grid PDF Export
Asked by
Arnþór
Top achievements
Rank 1
Answers by
Hetali
Telerik team
Share this question
or