react-checkbox-tree
react-checkbox-tree copied to clipboard
Ability to set indeterminate state for checkbox
It would be very useful to have the capability which lets you explicitly define if we want a node's checkbox to be in indeterminate state.
Something like:
{ value:'', label:'', children:[], checked: 'indeterminate/true/false' }
Or is there any way to accomplish this, if I am missing?
Currently this is not possible, but it may very well be supported in the future.
That'd be great!
For anyone following this, to implement it with the currently available options, I:
- Assigned a class(say, partially-selected-tree-node) to the node whose checkbox I wanted to be in indeterminate state.
- Set the indeterminate state for the checkbox to be true in componentDidMount and componentDidUpdate, whose parent has the assigned class.
const a = document.querySelectorAll('li.partially-selected-tree-node input[type="checkbox"]'); for (let i = 0; i < a.length; i += 1) { a[i].indeterminate = true; }
I don't know if it is acceptable to use javascript's query selector to achieve this but couldn't find any other way. Would really appreciate if there is a better way and I am missing it!
Any suggestions on this @jakezatecky ?
This may (emphasis may) be supported in a v2.0 release. The query selector approach can work though I have no reasonable alternatives until this is better supported by the component.
Hi @jakezatecky, is there any update on this?
Thanks in advance.