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

When a parent is checked is it possible to expand all its children nodes

Open bollampallyrohit opened this issue 2 years ago • 1 comments

Hello,

In our project we want to have a functionality where in when a parent with children is checked then expand all its children. So is it possible to do it

bollampallyrohit avatar May 01 '23 06:05 bollampallyrohit

There is no property to enable this behavior, but it is possible to code this yourself by setting the state of the expanded property within the onCheck function, by utilizing the second parameter:

const [checked, setChecked] = useState([]);
const [expanded, setExpanded] = useState([]);

function onCheck(checked, node) {
  setChecked(checked);
  setExpanded([...expanded, node.value]);
}

jakezatecky avatar May 07 '23 20:05 jakezatecky