Kendo Grid Excel Export with nested Detail/Child Grids

3 posts, 0 answers
  1. Alain
    Alain avatar
    8 posts
    Member since:
    Mar 2012

    Posted 28 Mar 2017 Link to this post

    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. Alain
    Alain avatar
    8 posts
    Member since:
    Mar 2012

    Posted 28 Mar 2017 in reply to Alain Link to this post

    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--) {

    ...

    }

  3. Stefan
    Admin
    Stefan avatar
    2894 posts

    Posted 30 Mar 2017 Link to this post

    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 visualization (charts) and form elements.
Back to Top