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

Removing rows for export

3 Answers 634 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 26 Jun 2019, 10:40 PM

How do I remove rows? Currently I do something like:

                    e.workbook.sheets.forEach(function (sheet) {
                        sheet.rows = sheet.rows.filter(r => r.type != "group-header");
                    });
                    e.sender.saveAsExcel();

But it seems that the saveAsExcel() function is ignoring the rows that I have filtered out?

3 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 28 Jun 2019, 12:55 PM
Hi Kevin,

Based on the provided code snippets, I suspect that the code is executed within an event handler. Can you specify in which event exactly? 

If the code is executed in the ExcelExport event handler, then the Maximum call stack exceeded exception would be thrown. This is due to the fact that the saveAsExcel method would call the ExcelExport event, therefore, infinite loop is created. 

What I can recommend is to do the modifications within the handler of the ExcelExport event. It would not be needed to explicitly call the saveAsExcel() method, and the changes would be present. Also, is it possible for you to check right after the filter method is the rows are changed. If not, then the initial collection would be exported. 

Ideally, it would be great if you can isolate the faulty behavior in a sample runnable project and send it back to me. This way, I would have the opportunity to examine the case locally and get back to you with suggestions.


Kind regards,
Tsvetomir
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.
0
Kevin
Top achievements
Rank 1
answered on 28 Jun 2019, 02:00 PM

This is how the handler is defined now:

 

.Events(events => events.DataBound("function(e) { Gartner.refreshFiltersForGrid('" + gridName + "'); Gartner.buildActionMenu(e);Gartner.GlobalAgendaTabGrid.onDataGridBound(e);}"
).ExcelExport("Gartner.GlobalAgendaTabGrid.excelExport"))

 

0
Tsvetomir
Telerik team
answered on 01 Jul 2019, 12:17 PM
Hi Kevin,

I have noticed that this thread is duplicated and my colleague Alex has already provided an answer to your query at:

https://www.telerik.com/forums/removing-aggregate-title-from-excel-export

In case there are additional questions, feel welcome to share them on the other thread.


Kind regards,
Tsvetomir
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
Kevin
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Kevin
Top achievements
Rank 1
Share this question
or