jakezatecky / react-checkbox-tree

A simple and elegant checkbox tree for React.

Home Page:https://jakezatecky.github.io/react-checkbox-tree/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Marking of parents with checked leafs

cvzbynek opened this issue · comments

Hello,

is there any elegant way to mark parent nodes with checked leafs? I would use node checkboxes, but I need to disable them, because I need only one leaf checked for each closest parent. Which leads me to the next question - is there any solution for restricting selection of leafs within node?

For the first question, you could show the parent node but use the disabled property on that node to prevent selection but allow leaf selections.

For the second question, there is no elegant or built-in feature in the checkbox to restrict selection toward a single leaf node,. However, it is possible. After onCheck is fired and a leaf is checked, you can modify the nodes propertyset sibling nodes todisabled: true. This would require traversing the original nodes` tree recursively.