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

Automatic child data update

I used hirarchical tree structure data table. I that i have button to add the child elements, After adding the child without refreshing it should show the data in table. But i am getting the data after refreshing the grid table. What is the way to update the child data dynamically

+ icon is used to add the child data to the parent OAM.

1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team October 18, 2019 09:29 AM UTC

Hi Dinesh, 

Greetings from Syncfusion support. 
Based on your query, we have prepared a sample and achieved your requirement in click event. we suggest you to follow the below way to achieve your requirement. Please refer the below sample and code example for more information. 

<ejs-grid #grid id='Grid' [dataSource]='hierarchygrid' (load)='onLoad($event)' [childGrid]='childGrid'> 
                 <e-column headerText='Button' width='150' textAlign='Center'> 
                <ng-template #template let-data> 
                    <div class="button"> 
                        <button ejs-button (click)="onClick($event)" #button>Buttons</button> 
onClick(args) { 
    var tr = args.target.closest('tr'); 
    var childId = tr.nextElementSibling.getElementsByTagName('div')[0].getAttribute('id'); 
    var grid = (document.getElementById(childId) as any).ej2_instances[0]; 
    if (tr.firstElementChild.getAttribute("aria-expanded") && grid) { 
      var data = { "id": 1, "Data": "Raja", "Adress": "shdgsjh", "contach": "973763633" }; 
      grid.editModule.addRecord(data, 0); 

Thavasianand S. 

Live Chat Icon For mobile
Up arrow icon