patternfly-bootstrap-treeview
patternfly-bootstrap-treeview copied to clipboard
Method checkNode doesn't restore partially-checked parents.
Hi,
I just found an issue when trying to programmatically check nodes via the checkNode method. Apparently the method passes the checked status onto the node's children however it doesn't set the partially-checked status on its parents when not all the siblings are checked. Take a look at the screenshot below. This is the result I'm getting with:
jQuery("#outfitsProductsTree").treeview('checkNode', [nodes2Check, { silent: false } ]);
(hierarchicalCheck: true)
as you can see the parent(s) of the 3 nodes I checked should have the partially-checked status yet they don't.
I digged a bit into the code and I found a workaround by using the toggleNodeChecked method instead. For some reason this method correctly sets the partially-checked status on the parents. So if I invoke:
jQuery("#outfitsProductsTree").treeview('toggleNodeChecked', [nodes2Check, { silent: false } ]);
with the very same nodes (nodes2Check) (and obviously hierarchicalCheck: true) I get the correct result:
Sorry I'm not sure how to fix it properly otherwise I'd have forked straight away.
Furthermore I'm still "forced" to use an old version due to Issue no.41
I hope the workaround helps for the time being
Hi, could you please verify with the latest version and if it's still happening please provide a fiddle. Thanks
This is still happening. The necessary code is only inside the toggleChecked function: https://github.com/patternfly/patternfly-bootstrap-treeview/blob/master/src/js/bootstrap-treeview.js#L725