jQWidgets Forums
jQuery UI Widgets › Forums › Angular › Angular update treeitem
Tagged: treeitem, treesource
This topic contains 8 replies, has 2 voices, and was last updated by Martin 6 years, 9 months ago.
-
AuthorAngular update treeitem Posts
-
Hello,
I have a treecomponent with source, the tree has multiple levels. i need to delete and update a particular node.
i have updated the source but in the ui it does not reflect, so i have used:
this.mytree.updateItem(node, newnode);
but this doesnt work for me.delete:
this.mytree.removeitem() worked but source is not getting updated.Hello TSKishore,
After you have updated your source, pass it to the tree again, like this:
this.myTree.source(this.source);
,
this will reflect in the ui.Best Regards,
MartinjQWidgets Team
http://www.jqwidgets.com/Hello Martin,
Thanks that worked.
For Delete : From source i’m not able to delete particular node.
Hello TSKishore,
You can ‘delete’ a node from your source by passing it an empty object.
this.source[1] = {};
When you pass the source to the tree again, the node will be removed from the ui.
Best Regards,
MartinjQWidgets Team
http://www.jqwidgets.com/Hello Martin,
I’m trying to delete a particular node from multi level tree.
If i pass empty object, a node labeled “item” is replacing the node which i deleted.
Hello TSKishore,
Then you can try removing the node from its array in the node using
splice
.
Here is a Demo for example.
Using ‘splice’ will remove the node and re-index the array.
In the above examplethis.treeSource[1] = {};
also works, but this would depend on the structure of your data.Best Regards,
MartinjQWidgets Team
http://www.jqwidgets.com/Hello Martin,
In Demo, only the first node is deleted. In my scenario I want to delete the child nodes of first node or so on.
or even node[i].items[i].items[i].Regards,
KishoreHello Martin,
Once I use splice on the particular node, I’m not able to add new node to that node.
Regards,
KishoreHello TSKishore,
You can use “splice” again to add new node to a particular position in the tree.
I’ve updated the Demo.
For this example, I only delete the second child of the first node and insert at the same position. Of course, you can modify this with your own logic.Here you can check how “splice” works for inserting items to an array.
Best Regards,
MartinjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.