I am new this ivh tree, https://github.com/iVantage/angular-ivh-treeview
I have been successfully able to configure this library, however I am not able to get the list of selected nodes, is there a way to get list of selected nodes programmatically?
The easiest way is to use ivhTreeviewBfs
to collect selected nodes.
var selectedNodes = []
ivhTreeviewBfs(myTree, function(node) {
if(node.selected) {
selectedNodes.push(node)
}
})
Note that you can use ivhTreeviewOptions
to get the appropriate "selected" attribute if you want to be fully generic. Also, folks will often want to only collect the top-most selected node for a given tree branch. In this case you can return false
in the callback passed to ivhTreeviewBfs
and that node's children will not be visited.
You can read more about the bfs service here.