We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Grid excel export without child grids.

Hi, 

how can I exclude the hierarchy grids of my main grid and export to excel the main one without those child grids?

I'm exporting with custom data, so I'm setting an ExcelExportProperties object to execute the grid.excelExport([thatObject]) and I tryied with hierarchyExportMode: "None" but its not working..

Is there any way to accomplish my request?

thanks

5 Replies

MS Manivel Sellamuthu Syncfusion Team August 9, 2019 09:37 AM UTC

Hi pk, 

Thanks for contacting us. 

Yes. You can achieve your requirement by removing child-Grid from grid Object in beforeExcelExport event and restoring in excelExportComplete complete event of the Grid. 

Please find the below code snippet for more information. 

@{ 
    var SecondChildGrid = new Syncfusion.EJ2.Grids.Grid() 
    { 
. . . 
} 
    }; 
    var ChildGrid = new Syncfusion.EJ2.Grids.Grid() 
    { 
. . . 
}, 
        ChildGrid = SecondChildGrid 
    }; 
} 
 
    <div class="control-section"> 
        <ejs-grid id="HierarchyPrint" dataSource="ViewBag.EmpDataSource" beforeExcelExport="beforeExport" excelExportComplete="exportComplete" childGrid="ChildGrid" toolbarClick="toolbarClick" toolbar="@(new List<string>() {"ExcelExport" })" 
                  allowExcelExport="true"> 
            <e-grid-columns> 
                <e-grid-column field="EmployeeID" headerText="Employee ID" textAlign="Right" width="125"></e-grid-column> 
                <e-grid-column field="FirstName" headerText="Name" width="120"></e-grid-column> 
                <e-grid-column field="Title" headerText="Title" width="170"></e-grid-column> 
                <e-grid-column field="City" headerText="City" format='yMd' textAlign="Right" width="135"></e-grid-column> 
            </e-grid-columns> 
        </ejs-grid> 
    </div> 
 
    <script> 
        function toolbarClick(args) { 
            if (args.item.text === 'Excel Export') { 
                this.excelExport(); 
            } 
        } 
        var childGrid; 
        function exportComplete(args) { 
            this.childGrid = childGrid; 
        } 
        function beforeExport(args) { 
            childGrid = this.childGrid; 
            this.childGrid = null; 
        } 
 
    </script> 


                             https://ej2.syncfusion.com/documentation/api/grid/#excelexportcomplete 

Please get back to us, if you need further assistance. 

Regards, 
Manivel 




PK pk August 12, 2019 06:13 PM UTC

thanks


PS Pavithra Subramaniyam Syncfusion Team August 13, 2019 05:57 AM UTC

Hi pk, 
 
Thanks for your update. 
 
Please get back to us if you need nay further assistance on this. 
 
Regards, 
Pavithra S. 



NI Nitish May 24, 2020 10:28 AM UTC

Hi,

Is there any way to export it with CHILD GRID?

Thanks.



RR Rajapandi Ravi Syncfusion Team May 25, 2020 08:42 AM UTC

Hi Nitish, 
 
Thanks for the update 
 
Query#: Is there any way to export it with CHILD GRID? 
 
Yes, you can export the it with Child Grid. We have already discussed about your requirement in our sample demos. Please refer the below sample demos link and screenshot for more information. 
 

Screenshot: 

 
 
Regards, 
Rajapandi R 


Loader.
Live Chat Icon For mobile
Up arrow icon