This is a migrated thread and some comments may be shown as answers.

Export parent and child grids to excel with tag helpers

1 Answer 201 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Owen
Top achievements
Rank 1
Owen asked on 14 Jun 2019, 12:07 PM
I have a solution that has been built with tag helpers, and wants the added functionality of exporting both the parent and child grids. Is this possible via tag helpers?

1 Answer, 1 is accepted

Sort by
1
Alex Hajigeorgieva
Telerik team
answered on 19 Jun 2019, 08:53 AM
Hello, Owen,

The built-in excel export is designed to export the current view of the widget it is initiated upon. The export uses the data only and has no knowledge of the detail templates and any other widget which may be added to the detail template. In order to handle the grid details and include them in the master grid excel export, we need to intercept the on-excel-export event and alter the created workbook programmatically.

Dependent on the current setup, there are various ways of how this may look like. Here are three options that I can think of:

1) Export only the current view as well as only the expanded children

We have an example for ASP.NET MVC in the repository here:

https://github.com/telerik/ui-for-aspnet-mvc-examples/blob/master/grid/detail-grid-excel-export/KendoUIMVC5/Views/Home/Index.cshtml

2) Export the all pages and all details. The difference here is the necessity to create a Kendo UI Data Source that reads the details separately and then populates the workbook

https://github.com/telerik/ui-for-aspnet-mvc-examples/blob/master/grid/detail-grid-excel-export-all-pages-all-details/KendoUIMVC5/Views/Home/Index.cshtml#L49

3) The master grid already contains the data for the child grid as part of a collection in the master model

- get the master dataSource view() and start adding rows to a Workbook
- loop over it looking for the child grids and their views 

https://dojo.telerik.com/@bubblemaster/AVAvOhiw/3

Let me know if you need further assistance.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Owen
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or