CirclonGroup / angular-tree-component

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

Missing documentation for how to use checkbox tri-state in a custom template #937

Open stuartngreen opened 2 years ago

stuartngreen commented 2 years ago

I'm not sure if this is just missing or it can't be done, but it seems like an oversight.

I would like to use the checkboxes with the tri-state functionality (parent child relationship) but within a custom template. I tried to assign the node.toggleSelected() method to the (change) event on a checkbox in a node, but it doesn't work (the toggleSelected() method is also missing from the Tree Node API reference page but it definitely exists).

The examples on the custom templates page which contain checkboxes don't have this tri-state functionality working... any help would be much appreciated.

madman-maverick commented 1 year ago

Hi @stuartngreen, I came across the same issue as you. It can simply be solved by using the following template for checkbox in your node's custom template: <input class="tree-node-checkbox" type="checkbox" (click)="node.mouseAction('checkboxClick', $event)" [checked]="node.isSelected" [indeterminate]="node.isPartiallySelected" />

Hope it helps!

stuartngreen commented 1 year ago

Thanks @madman-maverick I ended up writing a whole new checkbox tree because performance wasn't so good with thousands of checkboxes. But your reply will help someone I'm sure!