-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TreeView] Add checkbox support #6019
Comments
@cdwyer-cognito does Event.stopPropogation in the checkbox click handler help? |
@mbrookes I can confirm no, Event.stopPropagation() doesn't help. Using the following handler:
@cdwyer-cognito did you fix this in the end? |
Ok. fixed. After delving into the mui code, I realised the problem here. The So capturing the Anyhoo, simple fix is to give the checkbox an So here's a <Checkbox
id={`checkbox-${yourId}`}
checked={isChecked}
onChange={(e, checked) => (console.log('you checked it!', checked)}
onClick={e => (e.stopPropagation())}
{...props}
/> |
So sorry, I've not looked at this thread for a while. That looks a good solution, I'll give it a go and let you know. Thank you |
Great, that works perfectly. I had tried to stop the propergation on the onChange, I understand why that didn't work now. Thank you again. |
can you shair current code of checkbox treeview |
@RjSingh1529 my solution in typescript |
We probably need to have a dedicated |
@thclark please share your complete code with us . if it is possible. |
I don't understand the getChildByID code. Can you re-explain how you checked the child when the parent is checked. |
Added auto selection for parent when children are selected. And the same for deselection. |
@hamsishe great work! Any tips on how I could extend this to where the children could be a group of radio buttons (in addition to have checkboxes in the same parent) Ideally I am needing something that can extend to this Parent 1 Only one option in 1.3.1 should be allowed to be selected for radio boxes, checkboxs you can select N amount. |
Great sample. |
Hi @hamsishe Can you please tell me what to do when I don't have a root parent node? I mean the structure of data is an array of objects and not an object. I don't want the Parent label to render |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
1 similar comment
This comment was marked as off-topic.
This comment was marked as off-topic.
@hamsishe Do you know how to resolve this issue when the data's length === 200, the error will happen |
@Shivraj97 Just use data.map(item => renderTree(item)) |
@cpdwyer: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
See #12883 for the continuation of this issue, to get to the right checkbox selection behavior. |
Thanks for the Component, it works really well. Unfortunately I have come across on problem in the implementation which I can't seem to find a workaround for.
Summary 💡
I am looking to use the TreeView / TreeItem components with a check box on each row. Ideally I would like a prop to suppress the event that expands and collapses the tree if the CheckBox is clicked. Or maybe a prop to enable a checkbox with a prop to set the value and a call back when clicked that also avoids the list toggle.
At the moment when a check box is toggled it also expands and collapses the tree when the node has children.
Thank You.
Examples 🌈
This is the current code...
Motivation 🔦
see above
The text was updated successfully, but these errors were encountered: