Move tree nodes at root level

How do I move nodes at the root level? The moveNodes method only seems to work if you pass in a target node. This does not allow me to move nodes from a child node to root or reorder nodes at root level.

1 Reply 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team February 1, 2021 10:08 AM UTC

Hi Hosney,  
 
Greetings from Syncfusion support. 
 
We have checked your reported problem with TreeView component. Currently, we have not provided support for moving the nodes to root level of TreeView component. Based on your request, we have considered it as a feature request. Support for this feature will be included in any one of our upcoming releases. Generally, we will plan any feature implementation based on customer request count, feature rank and wishlist plan for some feature.  
  
Please, track the following feedback link to know the status of this feature implementation.  
 
 
However, we suggest you to use the removeNodes and addNodes method to achieve your requirement. 
 
document.getElementById("move").onclick = () => { 
  // get the node details. 
  var node_data = treeObj.getNode("2"); 
  let obj: any = { name: node_data.text, id: node_data.id }; 
  //remove the nodes using remove nodes method. 
  treeObj.removeNodes(["2"]); 
  //add the nodes using addNodes method. 
  treeObj.addNodes([obj], null); 
}; 

 
Please, refer to the below link for  more details on TreeView component. 
 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Sowmiya.P 


Marked as answer
Loader.
Up arrow icon