hummingbird-dev / hummingbird-treeview

A powerful and fast jQuery treeview plugin
MIT License
62 stars 23 forks source link

single checkbox select, parent-only select options #15

Open selaromdotnet opened 4 years ago

selaromdotnet commented 4 years ago

This control is pretty great, thanks for sharing! However, it appears there isn't any way to provide the option to only select one node.

I tried to work around this using the nodeChecked event by unchecking all but the selected node. This ALMOST works, however it does not allow the selction of a parent node specifically if it also has children, because when you deselect those, it in turn deselects the parent!

I looked over the code to see if this is something I could easily modify but it looks like you're traversing on each action and I had trouble unwrapping it to make this optional.

I'd like to fork this project and give it a try, but do you have any notes that I could use to achieve this change? any insight you have would be very helpful and appreciated!

hummingbird-dev commented 4 years ago

Thanks for using the treeview. The single-checkbox-select can be achieved like you did. However I use the getChecked method for that. I will inlcude a new section in the README, which deals with these add on functionalities, which can be achieved with some extra logic. I have to think about the parent-only-select, seems tricky because of the whole tri-state logic ... I'll come back to you soon.

hummingbird-dev commented 4 years ago

I've now included this new section: https://github.com/hummingbird-dev/hummingbird-treeview#add-on-options-and-functionality The "select-single-node" is straight forward. The "select-single-group" is a bit tricky. I'm not sure, if this is exactly what you were looking for. The idea is to allow one or more nodes to be checked within a group, but not across groups. I've also not tested it fully, so it's in an experimental state.