简体   繁体   中英

how to get list of selected nodes in angular ivh tree view?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM