amsik / liquor-tree

Tree component based on Vue.js
MIT License
398 stars 93 forks source link

Uncheck all children when a specific node is unchecked #166

Open ryanrapini opened 5 years ago

ryanrapini commented 5 years ago

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?

amsik commented 5 years ago

Hi! Yeah.

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

node1.recurseDown(node => {
 if (node.checked) {
  node.uncheck()
 }
})
ryanrapini commented 5 years ago

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

amsik commented 5 years ago

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