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

Can add nested nodes with addNodes() method?


I´m following the next example of "How to process the node operation in tree view using context menu" here: https://ej2.syncfusion.com/angular/documentation/treeview/how-to/#how-to-process-the-node-operation-in-tree-view-using-context-menu .
I probe by myself the same code changing item like this to add a nested item:
let item: { [key: string]: Object } = { id: nodeId, name: "New Folder", child: {id: 5, name: "Folder"} };
and doesn´t work, there is any solution?


3 Replies

CI Christopher Issac Sunder K Syncfusion Team November 29, 2018 10:52 AM UTC

Hi Jon Andoni, 

Thank you for contacting Syncfusion support. 

As per our analysis, the reported problem may occur due to the improper mapping on fields to form the data. Could you please ensure the mapping fields specification at your end? 

Here is the sample code for your reference,  

public onClick(){ 
    let item: { [key: string]: Object } = { id: "node1", name: "New Folder", hasChildren: true, subChild: [{ id: 5, name: "Folder" }] }; 
    this.tree.addNodes([item], this.tree.selectedNodes[0]); 

Please get back to us with more details if you are facing the same issue still. 


JA Jon Andoni November 29, 2018 01:23 PM UTC

Hello Christo,

Thanks for the solution, it works well ;)

CI Christopher Issac Sunder K Syncfusion Team November 30, 2018 05:38 AM UTC

Hi Jon Andoni, 

We are glad to hear that the provided solution worked for you. Have a great day!!! 


Live Chat Icon For mobile
Up arrow icon