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

Unable to get child element

Thread ID:





146555 Aug 8,2019 06:01 AM UTC Aug 8,2019 10:29 AM UTC Angular - EJ 2 1
Tags: Treeview
Anjali Kumari
Asked On August 8, 2019 06:06 AM UTC

I want to retrieve the child element in tree view to drag and drop the nodes. But unable to get it in treeview. I am attaching the json data and the structure of treeview I want. Please help me to retrive the child element. Attaching my json data in Zip file and also you can get the json data from this link: https://textuploader.com/11mz5
This is the tree structure that I want to have:

Attachment: data_3612040b.zip

Ashokkumar Balasubramanian [Syncfusion]
Replied On August 8, 2019 10:29 AM UTC

Hi Anjali Kumari 
Good day to you. 
We have checked your JSON data and prepared a sample based on your requirement. To render TreeView and for performing tree node operations such as adding a node, performing drag and drop operation, “id” plays an important role. In your shared data there is no “id” available for parent and child data so that the child nodes are not rendering. We have programmatically added id for parent and child data using the following code snippet. 
constructor(private dataService: DataService) { 
        this.dataService.getDataFromAPI().subscribe(response => { 
            var temp = Object.values(response); 
            var arr = []; 
            for (var i = 0; i < temp.length; i++) { 
                var stringifiedData = JSON.stringify(temp[i]).replace("title", "type"); 
                var addId = JSON.parse(stringifiedData); 
                // adds id for parent record 
                addId.id = i + 1; 
                // adds id for child record 
                for (var j = 0; j < addId.crime_types.length; j++) { 
                    addId.crime_types[j].id = addId.id + j + 1; 
            this.data = arr; 
            this.tree.fields.dataSource = this.data; 
If you want to get the data of particular node(with child item data), you can use the getTreeData method. 
Please check the sample and get back to us, if you need any further assistance on this. 
Ashokkumar B. 


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