CirclonGroup / angular-tree-component

A simple yet powerful tree component for Angular (>=2)
https://angular2-tree.readme.io/docs
MIT License
1.1k stars 492 forks source link

After selected checkbox. How can I review the information I have selected? #873

Open jaykittiwat opened 3 years ago

jaykittiwat commented 3 years ago

How to access the node that was selected or unselected with a checkbox in the tree?

tobiasengelhardt commented 3 years ago

Hi @jaykittiwat, I edited your question a bit. If you use the normal checkboxes shown in the docs you just have to listen to the select and deselect event. Example template:

<tree-root
      [nodes]="nodes"
      [options]="options"
      (select)="someThingSelected($event)"
      (deselect)="somethingDeselected($event)">
    </tree-root>

The event contains

{
    eventName: string // select or deselect
    node: TreeNode // node that was selected/deselected
    treeModel: TreeModel
}

With that you can get which node was selected and react to those events accordingly.