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

Load data dynamically from database when click on expand icon in treeGrid control


I'm using treegrid with angular & typescript to display hierarchical data. 
Initially I only load parent data using a service call (say getParents() method), which return much fewer json records.

Requirement is:
If user click expand icon for one parent record, it should make a service call for other method (say getChilds()) to get children records for the parent record and display them in treegrid control.

Please confirm if this is achievable in syncfusion using angular.
If yes, please provide me an example.

thanks in advance,

1 Reply

JD Jayakumar Duraisamy Syncfusion Team September 7, 2017 04:34 PM UTC

Hi Naresh, 
We have analyzed your given requirement and it can be achieved in TreeGrid by using load on demand support. To enable “Load on Demand” feature, we required “hasChildMapping” API to identify the parent node and “enableLoadOnDemand” as true.  
At initial, TreeGrid loaded with parent/root nodes in collapsed state from the remote server by using dataManager. After expand the parent record, corresponding child records are fetched from the webservice and added to respective parent record.  
As we are using remote data, so we should be either mention crossDomain as true in DataManager or use enableLoadOnDemand as true.  
Please refer following code snippet,  
<ej-treegrid #TreeGridControl [dataSource]="datasource" [treeColumnIndex]=1 
        idMapping = "TaskID" parentIdMapping="ParentID" hasChildMapping="isParent" 
        enableVirtualization = "true" enableLoadOnDemand="true" 
        sizeSettings.height="450px" sizeSettings.width="100%" > 
    public datasource = new ej.DataManager({ 
            crossDomain: true 
Please refer following document & online sample links,  
We have also prepared a demo sample with remote data from online webservice. Please find the sample location as below,  
Please let us know, if you require any other assistance.  
Jayakumar D 

Live Chat Icon For mobile
Up arrow icon