[HOW TO] Delete a node from a tree
See original GitHub issueI want to delete a node from a tree. Given nodeToDelete
, this method doesn’t work
The splice method doesn’t work, as soon as you call update() the item well be back
const itemIndex = nodeToDelete.index;
nodeToDelete.parent.children.splice(itemIndex, 1); // item disappear
this.tree.treeModel.update(); // item comes back again
If I use the array that I am binding to the tree then I can delete elements from the root as such
const itemIndex = nodeToDelete.index;
this.nodes.splice(itemIndex, 1);
this.tree.treeModel.update();
What if the node I want to delete is not in the root of the nodes
array i.e. it is a child of another node?
The first option clearly much better but it doesn’t work, the delete is not persisted in the tree.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Deletion in Binary Search Tree - GeeksforGeeks
1) Node to be deleted is the leaf: Simply remove it from the tree. 50 50 · 2) Node to be deleted has...
Read more >Deletion from BST (Binary Search Tree) - Techie Delight
Case 2: Deleting a node with two children: call the node to be deleted N . Do not delete N . Instead, choose...
Read more >Delete a node from Binary Search Tree - YouTube
Key moments. View all · delete a non leaf node · delete a non leaf node · delete a non leaf node ·...
Read more >Deletion in Binary Tree | Delete a node in Single Traversal
Complete Playlist on Trees Data Structures: https://www.youtube.com/playlist?list=PL1w8k37X_6L-E23tn3d6oXLW63pS8-5rmBinary Tree Deleting a ...
Read more >How to Delete a Node from a Binary Search Tree - YouTube
In this video I walk through how to delete nodes from a binary search tree. Specifically I explain how to delete : the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can use something like this:
@sulhome
You can try as below
and call
deleteNode
function from your HTML on node.Hope this will help
Pleas let me know output.
Thanks Abhi.