This is a migrated thread and some comments may be shown as answers.

[Solved] More drag and drop woes

0 Answers 108 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paul
Top achievements
Rank 1
Paul asked on 29 Sep 2010, 04:20 AM
Here is the basic treeView:
*  Parent #1
   * Child #1
   * Child #2
* Parent #2
   * Child #3

Here is a few hurdles I am trying to over come (with the JavaScript API):
1.  The user can only drag a child from it's current parent to another parent.
     - I have a JSON object stored in the Value of each node with a "type" property which says "Parent" or "Child" and on the Child nodes I have the Parent # stored as well so if I can determine when the user clicks and drags Child #1 to Parent #2 or above or below Child #3 (if the Child #1 is dropped on top of Child #3 then I will call a different operation).  I know I can do this via the OnNodeDropped method with the e.dropPosition property.  My question is there any way to determine where they are dropping the node in the OnNodeDrop method (since it can be canceled).  I don't see a e.dropPosition property and when I call e.preventDefault() in OnNodeDropped the child is still moved.  For now I will get around this by refreshing the tree after this error so the tree will be correct.  Also since there is a lot of logic going on during the OnNodeDropped method I need to make sure how to basically disable the node from being moved or if that is even possible at that point.

2. The user can only drag a parent node to another parent node.
    -This is similar in that I have the JSON object but I cannot seem to get the data in the OnNodeDrop method and canceling or calling e.preventDefault() does me no good in the OnNodeDropped() method.

Basically if I can get some more information about how to interact with the OnNodeDrop and OnNodeDropped methods it would be greatly appreciated.  Also if I could cancel the drag-and-drop action in the OnNodeDragStart() method I think it would be easier for the user to understand.

Thanks,
Paul
Tags
TreeView
Asked by
Paul
Top achievements
Rank 1
Share this question
or