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

How to bind this context to child grid

Thread ID:





144875 May 27,2019 10:27 AM UTC May 28,2019 12:47 PM UTC Angular - EJ 2 1
Tags: Grid
James Evangelist
Asked On May 27, 2019 10:27 AM UTC

is there any way to bind 'this' context of my component to child grid?

Example - I've got code for parent grid defined on TypeScript side like this: 

private childGrid: ChildGrid = {
     editSettings: { /*someSettings*/ },
     actionComplete (args: any) {
          // here I want to have 'this' context of my component to save data when this event triggers
     /* more config */

Hopefully, you can understand what I want to achieve.

Thavasianand Sankaranarayanan [Syncfusion]
Replied On May 28, 2019 12:47 PM UTC

Hi James,  

Thanks for contacting Syncfusion support  

Query: “is there any way to bind 'this' context of my component to child grid? 

From your query, we suspect that you want to get the parent Grid details (component instance) inside the childGrid actionComplete event. We have achieved your requirement by binding the this argument along with actionComplete event. Refer the below code example 

    <ejs-grid #Grid id='Grid' [dataSource]='parentData' [childGrid]='childGrid'> 
export class AppComponent { 
    public appGrid: GridComponent; 
      public parentData: Object[]; 
      public childGrid: any; 
      public secondChildGrid: any; 
      ngOnInit(): void { 
          this.parentData = employeeData;        
          this.childGrid = { 
              dataSource: orderDatas, 
              queryString: 'EmployeeID', 
              allowPaging: true, 
              actionComplete: onComplete.bind(this), 
              editSettings: {allowEditing: true}, 
              pageSettings: {pageSize: 6, pageCount: 5}, 
              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 } 
  function onComplete(args){ 
    let proxy  = this // this reutns appcomponent instance 
    this.appGrid; //here you can get the parent Grid instance.  

For your convenience we have prepared a sample which can be referred below  

Please get back to us if above solution did not match your requirement  

Thavasianand S.  


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