react-checkbox-tree icon indicating copy to clipboard operation
react-checkbox-tree copied to clipboard

Select only immediate child leaves when parent is checked

Open Shynobee opened this issue 6 years ago • 1 comments

Hello Everyone

So guys, i have a simple question

here we have parents/child tree

── Grand Parent  
│   └── Parent #when i click here it select all the users that are in child 1 and 2 except that it don't select user that are only in parent
│   │   ├──  Child 1 #when i click on child number one it select the users inside child 1 (normal behaviour, same with child 2)
│   │   ├──  Child 2  

Now here's my question, how do i select users that are only in parent but not in childrens ? Is this possible with react-checkbox-tree ? If not will it be available someday ?

thanks for your time (and sorry if my english seems bad)

greetings from France and have nice holidays

Shynobee avatar Dec 28 '18 16:12 Shynobee

Hello.

When you say users that are in the parent, is this an appropriate modeling of your tree?

── Grand Parent  
│   └── Parent 1
│   │   ├──  Child 1
│   │   │   ├──  User 1-1
│   │   │   ├──  User 1-2
│   │   ├──  Child 2
│   │   │   ├──  User 2-1
│   │   │   ├──  User 2-2
│   │   ├──  User 1
│   │   ├──  User 2

If I understand you correctly, you would in this scenario only like for User 1 and User 2 to be selected when clicking the parent?

Currently, that behavior is not possible. We have a property, noCascade, that when a parent is clicked none of the children are clicked (and the parent is thus selected by itself), which is somewhat similar.

This type of behavior could be added. It would likely necessitate a more general cascade property that determines whether the default is to select all children, select only all immediate leafs (in this case), or do not select any children (as in the case of noCascade).

jakezatecky avatar Jan 22 '19 06:01 jakezatecky