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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Logging Row data of child grid on button click

Thread ID:





146968 Aug 27,2019 08:53 AM UTC Aug 30,2019 06:16 AM UTC Angular - EJ 2 3
Tags: Grid
Kunal Bajaj
Asked On August 27, 2019 09:13 AM UTC

Hi Team,

I have implemented a hierarchy grid, in which the childgrid is having a Details button. On clicking that Details button I want to access information of the entire row. Can you help me with the event that I could use to capture the data of the row for which details is clicked. 

Code Sample: 

It is not capturing the current Click event.

Dhivya Rajendran [Syncfusion]
Replied On August 28, 2019 12:47 PM UTC

Hi Kunal, 
Thanks for contacting Syncfusion support. 
We have validated the provided code example and you can achieve your requirement by using following way. Please refer the code example and sample for more information. 
<ejs-grid #Grid id='Grid' (click)='click($event)' [dataSource]='parentData' [childGrid]='childGrid'> 
    <e-column field='EmployeeID' headerText='Employee ID' width='120' textAlign='Right'></e-column> 
    <e-column field='FirstName' headerText='Name' width='140'></e-column> 
    <e-column field='Title' headerText='Title' width='170'></e-column> 
    <e-column field='HireDate' headerText='Hired Date' width='120' format='yMd' textAlign='Right'></e-column> 
    <e-column field='ReportsTo' headerText='Reports To' width='120' textAlign='Right'></e-column> 
export class AppComponent { 
  . . . . . 
  click(e) { 
    // add class for the template button 
    if (e.target.classList.contains('btn')) { 
       let gridEle = parentsUntil(e.target,'e-grid'); // get current child parent element 
       let gobj = gridEle['ej2_instances'][0]; // create current child grid instance 
       // get row information 
  ngOnInit(): void { 
    this.parentData = employeeData; 
    this.childGrid = { 
      . . . . . 
      columns: [ 
        { field: 'OrderID', headerText: 'Order ID', textAlign: 'Right', width: 120 }, 
        { field: 'ShipCity', headerText: 'Ship City', width: 120 }, 
        { field: 'Freight', headerText: 'Freight', width: 120 }, 
        { field: 'ShipName', headerText: 'Ship Name', width: 150 }, 
        { headerText: 'Action', width: 120, template: '<div><button class="btn">Details</button></div>' } 
In above example we have bind the click event for Grid and we can get current the row details from the child Grid by using getRowInfo method of Grid. 

Kunal Bajaj
Replied On August 29, 2019 12:36 PM UTC

Thanks a lot for the solution. Worked in a single go for me. Really appreciate your help :)

Dhivya Rajendran [Syncfusion]
Replied On August 30, 2019 06:16 AM UTC

Hi Kunal, 
Thanks for your update. 
We are happy that the provided solution was helpful to achieve your requirement. 
Please get back to us if you need further assistance from us. 


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