react-checkbox-tree
react-checkbox-tree copied to clipboard
Radio selections
I need this checkbox tree to be single select. is it possible?
Can you elaborate on what you mean by single select?
I guess I had the same need as you @parastooebrahimi
You can hide checkboxes of parent node using the showCheckbox
property on the nodes declaration.
Like:
const nodes = [
{
label: 'parent node',
value: 'parent1',
showCheckbox: false,
children: [...]
},
...
];
Then you can force the tree to single select using:
function onNodeCheck(nodeIds, node) {
if (singleSelect) {
setChecked([node.value]);
} else {
setChecked(nodeIds);
}
}
<CheckboxTree onCheck={ onNodeCheck } ... />
Hope it might help.
@dpellier can you elaborate the solution?