EJ2 Grid: Excel Export of Child Grid Only

I have a grid that has a child and grandchild grid.  On the child grid, I have the ExcelExport toolbar item, but how do I reference the child grid only to execute the .excelExport(); on?

Thanks!

7 Replies

VS Vignesh Sivagnanam Syncfusion Team April 20, 2021 02:11 PM UTC

Hi Mark 

Greetings from Syncfusion support 

Based on your query, you want to export the child grid using the toolbar click. We prepared a sample and you can get the childgrid instance using this keyword in the EJ2 Grid toobarClick event and. Please refer the below Code example and sample for your reference, 


function toolbar(args: any): void { 
  this.excelExport(); 

Regards 
Vignesh Sivagnanam 



MA Mark April 20, 2021 03:06 PM UTC

That's what I thought, but its not working at all.  No errors or anything within the console.  The console shows the 2 logs (Export and Exported) but no excel files.

This is our childGrid toolbar click function:

function grid_removal_requests_child_toolbarClick(args) {
            if (args.item.text == 'Excel Export'){
                console.log('Export');
                this.excelExport();
                console.log('Exported');
            }
        }

The grid is basically like this but with columns and the correct functions:

var exampleGrid = new ej.grids.Grid({
                dataSource: arrParentData,
                columns: [{
                    { field: 'id', headerText: 'ID', isPrimary: true, visible: false, allowSearching: false, },
                }]
                childGrid: {
                    dataSource: arrChildData,
                    queryString: 'request_id',
                    allowExcelExport: true,
                    toolbar: ['ExcelExport'],
                    toolbarClick: function (args ){
                        this.excelExport();
                    }
                    columns: [{
                        { field: 'id', headerText: 'ID', isPrimary: true, visible: false, allowSearching: false, },
                    }],
                    childGrid: {
                        dataSource: arrChildData,
                        queryString: 'request_items_id',
                        columns: [{
                            { field: 'id', headerText: 'ID', isPrimary: true, visible: false, allowSearching: false, },
                        }],
                    }
                }
            });




VS Vignesh Sivagnanam Syncfusion Team April 21, 2021 11:17 AM UTC

Hi Mark 

Thanks for the update 

Based on your query you are not able to perform excel export feature in the grid. Based on your code example we prepared a sample but we are not able to reproduce the reported issue at our end. 

Please refer the below sample and Video demo for your reference, 



If you still faced the reported issue at our end, Please share the below details to validate further on this, 

  1. If possible, replicate the issue in above sample or share issue reproduced sample.

  1. Syncfusion package version.

Regards 
Vignesh Sivagnanam 



MA Mark April 22, 2021 01:25 PM UTC

Sorry for the delayed response.  The stackblitz you have provided below does not work in Chrome.  The grid shows up, I can see data, you expand a row and click the button.  Nothing happens.  The console in stackblitz shows the 2 console logs, but the file never downloads.  Any thoughts?  Is my browser stuck on something?  

EDIT:  I just tried Edge and it works, so there is something messed up in my browser.  Thank you guys.


VS Vignesh Sivagnanam Syncfusion Team April 26, 2021 01:13 PM UTC

Hi Mark 

Thanks for the update. 

We checked the attached sample in our chrome browser ( version - 89.0.4389.128) but we did not face the mentioned issue at our end.  

Please refer the below video demo for your reference. 



For your convenience we have attached the local sample and please download the sample from the following link, 


If you still faced the issue, please share your chrome browser version that the issue is reproduced.  

Regards 
Vignesh Sivagnanam 



MA Mark April 28, 2021 11:28 PM UTC

Thank you.  We could not get this solved using your code, but solved it another way.  I fear we have something else going on with the grid, but none the less, we are working.


VS Vignesh Sivagnanam Syncfusion Team April 29, 2021 10:41 AM UTC

Hi Mark  

Thanks for your update. 

Please get back to us at anytime if you need further assistance. 

Regards 
Vignesh Sivagnanam 


Loader.
Up arrow icon