phphe / vue-draggable-nested-tree

Vue2 draggable tree component
https://hetree.phphe.com/
MIT License
344 stars 62 forks source link

Rejec drop based on node parent property? #50

Open caiokawasaki opened 5 years ago

caiokawasaki commented 5 years ago

I'm facing a little problem. When I call :ondragend="dragEnd".

This is my node structure:

{
    description:"Minima nihil quia maiores sunt perferendis dolorem aut.",
    id: 2,
    identifier: "10000.10000",
    open: true,
    type: 1,
    value: "Repellat ut veniam labore enim quasi ad temporibus."
}

Inside the dragEnd function when I try to access the parent node it always return the previous parent node. How can I solve this?

dragEnd(node) {
    if (node.parent.type != 1) {
        return false
    }
}
phphe commented 5 years ago

you can use the parent of drag placeholder. code: tree.dplh.parent or: node._vm.store.dplh.parent

caiokawasaki commented 5 years ago

node._vm.store.dplh.parent worked! But how can I access tree inside my dragEnd() function?

phphe commented 5 years ago

store is tree. https://github.com/phphe/vue-draggable-nested-tree#node-deep-properties-example