Skip to content
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

Select parent when child selected #21

Closed
renant opened this issue Feb 26, 2019 · 7 comments
Closed

Select parent when child selected #21

renant opened this issue Feb 26, 2019 · 7 comments

Comments

@renant
Copy link

renant commented Feb 26, 2019

I'm trying to select a parent when one of your children is selected, can I do that?

@azizali
Copy link
Owner

azizali commented Feb 26, 2019

Great question.

The onCheckToggleCb callback function will only get the list of nodes that got toggled.
The onUpdateCbcallback will get the full data.

You can determine the parent of checked/unchecked node by finding it in the full tree.

@renant
Copy link
Author

renant commented Feb 27, 2019

So the correct one would implement on the onUpdateCb callback, I was trying on the onCheckToggleCb callback ...

I'll try later with onUpdateCb and report here

Thank you

@azizali
Copy link
Owner

azizali commented Feb 27, 2019 via email

@renant
Copy link
Author

renant commented Mar 1, 2019

Hi @azizali , how's it going?

Sorry for the delay, I was able to do this through a combination of 'onCheckToggleCb' and 'onUpdateCb'

I got the last selected node in 'onCheckToggleCb' and found the parent by reference in 'onUpdateCb' and checked this

Thanks for the help, and sorry my bad english

@azizali
Copy link
Owner

azizali commented Mar 2, 2019 via email

@renant renant closed this as completed Mar 5, 2019
@c623700
Copy link

c623700 commented May 22, 2020

Hi @azizali , how's it going?

Sorry for the delay, I was able to do this through a combination of 'onCheckToggleCb' and 'onUpdateCb'

I got the last selected node in 'onCheckToggleCb' and found the parent by reference in 'onUpdateCb' and checked this

Thanks for the help, and sorry my bad english

I would interest in how you implement your solution, specially how to manage to pass the reference of the box that was checked, to the onUpdateCb. Thanks in advance

@ghost
Copy link

ghost commented Sep 10, 2020

I strongly recommend using react-checkbox-tree if you need this functionality (which is a must for a tree-view component). I hardly managed to check the upper parents but even in that case component doesn't half-check the parent and couldn't make it do that since it's not created considering this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants