Removing rows for export

4 posts, 0 answers
  1. Kevin
    Kevin avatar
    36 posts
    Member since:
    Jul 2018

    Posted 26 Jun 2019 Link to this post

    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?

  2. Tsvetomir
    Admin
    Tsvetomir avatar
    790 posts

    Posted 28 Jun 2019 Link to this post

    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.
  3. Kevin
    Kevin avatar
    36 posts
    Member since:
    Jul 2018

    Posted 28 Jun 2019 in reply to Tsvetomir Link to this post

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

     

  4. Tsvetomir
    Admin
    Tsvetomir avatar
    790 posts

    Posted 01 Jul 2019 Link to this post

    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.
Back to Top