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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

get grid instance from toolbarClick

Thread ID:

Created:

Updated:

Platform:

Replies:

141176 Nov 28,2018 12:06 PM UTC Dec 3,2018 05:26 AM UTC Angular - EJ 2 5
loading
Tags: Grid
Manolo Capdevila
Asked On November 28, 2018 12:06 PM UTC

Hi,

I've 3 grids in component.

How can I get the grid instance in toolbarClick.

I need some similar at this

toolbarClick(args: ClickEventArgs): void {
const grid: GridComponent;
grid = args.item.controlParent;
switch (args.item.text) {
case 'PDF Export':
grid.pdfExport();
break;
case 'Excel Export':
gridResumen.excelExport();
break;
case 'CSV Export':
grid.csvExport();
break;
}
}


But grid variable, is not GridComponent

Thavasianand Sankaranarayanan [Syncfusion]
Replied On November 29, 2018 04:54 AM UTC

Hi Manolo, 

Thanks for contacting Syncfusion support. 

You can get the grid instances from the ‘this.grid’ parameter in the toolbarClick event of Grid. 

Refer the help documentation. 



Regards, 
Thavasianand S. 


Manolo Capdevila
Replied On November 29, 2018 11:08 AM UTC

Hi,

With this.grid I need save the grid reference in grid vairable.

My question is if, since ClickEventArgs, I can get the grid reference for export.


I've three different grids, so if in toolbarClick function, I can get the grid instance, I don't need save each grid reference in different variables

Thanks

Madhu Sudhanan P [Syncfusion]
Replied On November 30, 2018 06:22 AM UTC

Hi Manolo,  

Thanks for contacting Syncfusion support. 

You can use the same event handler for multiple grid by passing the template variable as the argument of the event as follows. 


    <ejs-grid #grid (toolbarClick)='toolbarClick($event, grid)' [allowExcelExport]='true' [allowPdfExport]='true' > 
        ... 
    </ejs-grid> 
 
    <ejs-grid #grid5 (toolbarClick)='toolbarClick($event, grid5)' 
                [allowExcelExport]='true' [allowPdfExport]='true'> 
       ... 
    </ejs-grid> 


export class ExportingComponent implements OnInit { 
  ... 
  toolbarClick(args: ClickEventArgs, grid: GridComponent): void { 
      switch (args.item.text) { 
          case 'PDF Export': 
              grid.pdfExport(); 
              break; 
          ... 
      } 
  } 
} 





Regards,  
Madhu Sudhanan P

Manolo Capdevila
Replied On November 30, 2018 01:28 PM UTC

Thanks!

Thavasianand Sankaranarayanan [Syncfusion]
Replied On December 3, 2018 05:26 AM UTC

Hi Manolo, 
 
We are happy that the problem has been solved. 
 
Please get back to us if you need any further assistance.  
                          
Regards, 
Thavasianand S.                         


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon