Hi there, what you want should be possible, the exact implementation will depend on where in the tree you are when you want to get the parentId. The key is that I don't think you can use editorState, instead you have to inject appState and treeService into your angular controller
This will get the top most node of the current tree:
var rootNode = appState.getTreeState("currentRootNode");
This will get the current selected node in the custom tree
var selectedNode = appState.getTreeState("selectedNode");
If the current selected node has a parent the parentId property will have the appropriate value.
If you want to do more the treeService has various methods to get children & descendants taking section name and node (retrieved using methods above) as arguments.
How to get the parentId of the current node in custom tree using angularjs
Hi ,
i have a tree structure like
Tree1
Tree2
1.Item 1
2.Item 2
i am trying to get the parentId of Item2 of Tree1 using angular js. can we do it?is there any property using we can do it?
Thanks,
Hi there, what you want should be possible, the exact implementation will depend on where in the tree you are when you want to get the parentId. The key is that I don't think you can use editorState, instead you have to inject appState and treeService into your angular controller
This will get the top most node of the current tree:
This will get the current selected node in the custom tree
If the current selected node has a parent the parentId property will have the appropriate value.
If you want to do more the treeService has various methods to get children & descendants taking section name and node (retrieved using methods above) as arguments.
See the tree service in the umbraco source here for details https://github.com/umbraco/Umbraco-CMS/blob/d50e49ad37fd5ca7bad2fd6e8fc994f3408ae70c/src/Umbraco.Web.UI.Client/src/common/services/tree.service.js
Thanks a lot Ian :)
is working on a reply...