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

Kendo Grid Excel Export with nested Detail/Child Grids

2 Answers 590 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alain
Top achievements
Rank 1
Alain asked on 28 Mar 2017, 07:04 PM

Hello, I am having a hard time getting this to work even after following solutions such as these:

 

http://docs.telerik.com/aspnet-mvc/helpers/grid/how-to/Export/detail-grid-export

 

I have a main grid, and detail grid that can go up to 5 levels down, and wish to export the child data as well as the main data in the same workbook.  I have attached what my actual grid looks like in action (had to redact some text):

 

Main Grid:

@(Html.Kendo().Grid<...>()
        .Name("...")
        .Scrollable(s => s.Height("auto"))
        .HtmlAttributes(new { @class = "hidden", style = "height: 100%" })
        .Columns(columns =>
        {
            columns.Bound(...)
        .ClientDetailTemplateId("gridTemplate")
        .Events(e => e.DataBound("onMainGridDataBound").ExcelExport("onMainGridExcelExport").DetailInit("onMainGridDetailInit"))
        .Sortable()
        .Excel(xls => xls.FileName("Export.xlsx"))
        .Pdf(pdf => pdf.FileName("Export.pdf"))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model =>
            {
                ...
            })
            .Group(...)
            .Read(read => read.Type(HttpVerbs.Post).Action("..", "Grid").Data("..."))
            .Events(events =>
            {
                events.RequestEnd("onMainGridRequestEnd");
                events.Error("onError");
            })
        )
    )

 

Detail Grid:

<script type="text/x-kendo-template" id="gridTemplate">
    @(Html.Kendo().Grid<...>()
        .Name("..._#=UniqueId#")
        .Columns(columns =>
        {
            columns.Bound(...)
        .Pageable()
        .Sortable()
        .Excel(xls => xls.FileName("Detail Export.xlsx"))
        .ClientDetailTemplateId("gridTemplate")
        .Events(e => e.DataBound("onMainGridDataBound").ExcelExport("onDetailGridExcelExport").DetailInit("onMainGridDetailInit"))
        .ToClientTemplate()
    )
</script>

 

2 Answers, 1 is accepted

Sort by
0
Alain
Top achievements
Rank 1
answered on 28 Mar 2017, 07:34 PM

Following this example:

 

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

 

And stepping through, it seems as though my detailExports variable has no data when attempting to loop:

 for (var i = detailExports.length - 1; i >= 0; i--) {

...

}

0
Stefan
Telerik team
answered on 30 Mar 2017, 08:02 AM
Hello Alain,

Please check if the .then() promise is containing the expected arguments used to make the detailExports variable.

If not, check if there is a custom logic which may interfere with the promise and its arguments.

If additional assistance is needed, please send a fully runnable example reproducing the issue and I will gladly assist.

Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
Tags
Grid
Asked by
Alain
Top achievements
Rank 1
Answers by
Alain
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or