Parent/Child Grid Toolbar click

I have child grids under parent rows within grid (standard Paren/Child relationship) on each child grid i have toolbar with custom actions on them. the problem is if user directly clicks on toolbar button. I can't seem to get the current Child grid control. which is necessary for me to convert every row into JSON to store them in my database. 

So far from args parameter i could not find the current grid id when clicked on custom button in toolbar.

what should be my strategu 


1 Reply 1 reply marked as answer

JC Joseph Christ Nithin Issack Syncfusion Team November 19, 2021 12:50 PM UTC

Hi PDev,  Greetings from Syncfusion support.  Based on your requirement, you want to get the instance of the current child grid when you click on the custom button in the toolbar of your child grid. Also, you want to get the id of the current child grid when you click on the custom button in the toolbar.  Please refer the below code example, which demonstrates an example of how to get the instance and id of the current child grid when you click on the toolbar's custom button. 
this.childGrid = { 
      dataSource: orderDatas, 
      queryString: 'EmployeeID', 
      allowPaging: true, 
      pageSettings: { pageSize: 6pageCount: 5 }, 
      toolbar: ['CustomButton'], 
      toolbarClick: function (args) { 
        if (args.item.text === 'CustomButton') { 
          var currentChildGrid = args.originalEvent.target 
            .closest('tr') 
            .getElementsByClassName('e-grid')[0].ej2_instances[0]; 
          console.log(currentChildGrid.element.id); 
        } 
      }, 
      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 }, 
      ], 
    }; 
Please find the attached sample and get back to us for further details.Regards,Joseph I. 


Marked as answer
Loader.
Up arrow icon