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

Kendo Grid Excel Export with nested Detail/Child Grids

3 Answers 1302 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>

 

3 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.
0
Stevan
Top achievements
Rank 1
Iron
Iron
answered on 26 Dec 2022, 11:18 AM
Hello there. I have issue with exporting nested grid data in latest kendo ui release.
I've followed this link https://docs.telerik.com/kendo-ui/knowledge-base/detail-grid-export but I see there is kendo.ExcelExporter function which does not exist. Am I missing something here? Also all the data we have is retrieved with one request (parent and child data) I just need to export all the data together into an excel sheet. We have logic for parent data export working already but I could not find a way to make it work yet. 
Nikolay
Telerik team
commented on 27 Dec 2022, 11:26 AM

Hi Stevan,

Are you using the Kendo UI for jQuery Grid or KendoReact Data Grid or another Grid? I am asking this because this thread is discussing the Kendo UI for the jQuery framework and if your question targets another framework you will have to ask it in another thread.

Kendo UI for jQuery and KendoReact are different suites and they have different dedicated teams. I will be bale to help here with the first one only.

Regards,

Nikolay

Stevan
Top achievements
Rank 1
Iron
Iron
commented on 27 Dec 2022, 12:32 PM

Hello Nikolay.
Thank you for the reply. The issue I am facing is related to kendo ui for jquery
Nikolay
Telerik team
commented on 28 Dec 2022, 02:42 PM

Hi Stevan,

Thank you for confirming this with me.

Is not possible to set a TypeScript definition for the kendo.ExcelExporter in the kendo.all.d.ts. 

The recommended approach is to place the JavaScript declaration directly in a script tag as demonstrated in the article you have shared.

Regards,

Nikolay

 

Stevan
Top achievements
Rank 1
Iron
Iron
commented on 09 Jan 2023, 05:03 AM

Hello Nikolay,
We do have cdn file copied locally and use that as our main reference for kendo. It is up to date with latest version but I still get the same warning that the function does not exist.
I also tried approach from the example I linked by referencing it in html but issue is the same.

Best regards,
Stevan

Georgi Denchev
Telerik team
commented on 10 Jan 2023, 12:36 PM

Hi, Stevan,

The kendo.ExcelExporter is a method that is primarily used internally, that is why there is no public documentation or typescript definition for it. If the kendo.all script is included on the page, you'll be able to verify the existence of the method by opening the Devtools console(F12) and typing kendo.ExcelExporter:

If I understand correctly, the problem that you're facing is that you get a TypeScript warning about the method and not that the method does not work at all, correct?

If that is the case, you can ignore the warning on that particular line in order to compile the script. The alternative is to use the logic from the KB example in a regular js file like my colleague mentioned.

Let me know in case I missed something.

Best Regards,

Georgi

Stevan
Top achievements
Rank 1
Iron
Iron
commented on 23 Jan 2023, 09:25 AM

Hello Georgi,
Thank you for you answer, for some reason there was no notification so I only see it now.
I managed to 'bypass' the issue with TS fix.
I have one more question though. Since we are getting data from one request do I need to use $.when.apply and await for data or not? (and only apply logic to iterate thought already existing data)

Best regards,
Stevan
Georgi Denchev
Telerik team
commented on 25 Jan 2023, 08:06 AM

Hi, Stevan,

I am glad you managed to solve the problem.

Answering the question regarding the $.when is a bit difficult as it depends on the rest of the logic. Generally speaking, it is always a good idea to await for all data to be loaded before executing additional logic as this eliminates the possibility of missing records or some other logic not being applied.

In the KB example, $.when is needed because the logic requires for the child grids to be exported before it proceeds to creating the main SpreadSheet. If you don't need such logic then no, $.when will likely not be needed.

Still, the best advice I can give is to simply try both approaches and see which one works best with the current implementation of your application.

Best Regards,

Georgi

Stevan
Top achievements
Rank 1
Iron
Iron
commented on 26 Jan 2023, 03:42 PM

Hello Georgi,
I see. Thank you for suggestion :)

-Stevan
Tags
Grid
Asked by
Alain
Top achievements
Rank 1
Answers by
Alain
Top achievements
Rank 1
Stefan
Telerik team
Stevan
Top achievements
Rank 1
Iron
Iron
Share this question
or