liquor-tree icon indicating copy to clipboard operation
liquor-tree copied to clipboard

Uncheck all children when a specific node is unchecked

Open ryanrapini opened this issue 4 years ago • 3 comments

Hey there! I love this library. I'm struggling with what seems to be a limitation of the library API:

Is there a way to get all children of a given node? I want to call .children().uncheck() or something similar but there seems to be no such feature

By default I need to disable the autoCheckChildren functionality, so i set autoCheckChildren: false, in options.

Then I want to uncheck all children ONLY when a specific node is unchecked like this:

node 1
  |- node 2
  |- node 3
     |- node 4
node 4

when node 1 becomes unchecked I would like to force all children to become unchecked. Is there a way to do this?

ryanrapini avatar Sep 24 '19 08:09 ryanrapini

Hi! Yeah.

const node1 = this.$refs.tree.find('node 1')

node1.recurseDown(node => {
 if (node.checked) {
  node.uncheck()
 }
})

amsik avatar Sep 24 '19 12:09 amsik

Thanks! I can't see that anywhere in the documentation, I guess I need to look through the source code to find it?

ryanrapini avatar Sep 24 '19 21:09 ryanrapini

Yes. I don't have time to fill the documentation... :( Or you can aks here :)

amsik avatar Sep 25 '19 12:09 amsik