Articles in this section

How to Get Vue Diagram Child Nodes from Deleted Nodes?

This article explains how to get Vue Diagram child nodes from deleted nodes. Syncfusion® Vue Diagram provides various Automatic Layout algorithms. In these layouts, nodes are organized with parent-child relationships. When a node is selected and a delete operation is performed, typically only the connectors associated with the node are removed. This is the default behavior, even when using a layout algorithm.

By default, when deleting a parent node, the child nodes are not deleted. Only the connectors related to the parent node are removed, leaving the child nodes in the diagram.

However, if you need to delete the child nodes, we have a solution for it. When deleting a selected node, we can retrieve the outgoing connectors from the node using its outEdges property. With the outEdges property, we can access the connector object and retrieve the child nodes connected to it via the connector’s targetID. Using these IDs, we can remove the child nodes associated with the deleted node.

We have mapped the solution to usehandle delete option and Custom commands keyboard delete button manually.
The following code illustrates how to get child nodes from deleted nodes in the layout:

let deltednode = diagramInstance.selectedItems.nodes[0]
let outEdgesColl = deltednode.outEdges;
for (var i = outEdgesColl.length; i >= 0; i--) {
   let targetChild = diagramInstance.getObject(outEdgesColl[i]);
   if (targetChild) {
       let child = diagramInstance.getObject((targetChild).targetID);
       diagramInstance.remove(child);
   }
}
diagramInstance.remove();

Refer to the working sample for additional details and implementation: Sample

Conclusion

We hope you enjoyed learning how to get Vue Diagram child nodes from deleted nodes.

You can refer to our Vue Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Vue Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied