Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preventing drop for certain tree nodes #89

Open
dini-m opened this issue Aug 8, 2019 · 8 comments
Open

Preventing drop for certain tree nodes #89

dini-m opened this issue Aug 8, 2019 · 8 comments

Comments

@dini-m
Copy link

dini-m commented Aug 8, 2019

Hello phphe,

I am trying to limit the dropping of certain tree nodes underneath certain other tree nodes. Now I have different text in the data array and want to forbid that a tree node with the text 'A' from being child of a tree node with text 'B', even though they are droppable. Which position is the best to place this limitation? I tried putting the code in autoMoveDragPlaceHolder, in append and append Prev, and also in the function insertDplhAfterTo, but it doesn't work properly. It would be great if you could tell me what the append, prepend and the likes actually do.

Thanks in advance.

@phphe
Copy link
Owner

phphe commented Aug 9, 2019

ondragend: {type: Function}, // hook. return false to prevent drop. arguments(node, draggableHelperInfo)
node._vm.store.dplh // placeholder
node._vm.store.dplh.parent
node._vm.store.dplh.parent.text
node.text

@dini-m
Copy link
Author

dini-m commented Aug 9, 2019

I see. But how do I get the info of the target node, underneath of which another node is to be placed at? I don't see any variable called targetNode in the node. I want to forbid dropping underneath of a node, not as a child node.

@phphe
Copy link
Owner

phphe commented Aug 12, 2019

the placeholder will be replaced after drop, so think placeholder(dplh) as target node.

@dini-m
Copy link
Author

dini-m commented Aug 12, 2019

I mean, I need to get the information of the previousSibling, if I I were to drop a node at a new location. dplh is just the placeholder and doesn't contain any information about the text of the previous node.

@phphe
Copy link
Owner

phphe commented Aug 14, 2019

// previousSibling
index = dplh.parent.children.indexOf(dplh)
dplh.parent.children[index-1] 

@dini-m
Copy link
Author

dini-m commented Aug 14, 2019

Oh I did the same thing. Thanks for your help!

@dini-m
Copy link
Author

dini-m commented Aug 15, 2019

Oh one other question. Is it possible to prevent dropping of a tree node from another tree underneath a certain tree node ? Because the ondragend function is only called when the dragged tree node comes from the same tree. If it comes come from another tree, only ondrop function is called. Returning false here does not forbid dropping. And my trees need to crossTree.

@dini-m
Copy link
Author

dini-m commented Aug 16, 2019

oh don't mind that question earlier. I have solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants