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

How to determine DropPosition *before* dropping

1 Answer 68 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Sebastian P.R. Gingter
Top achievements
Rank 2
Sebastian P.R. Gingter asked on 30 Dec 2010, 03:07 PM
Hi,

I need the dropPosition (like I could request in the nodeDropping event from the eventArgs) already in the nodeDragging event.

The issue is that I can sort nodes within the tree (drag them in between) and certain nodes (determined by an attribute value) may be moved everywhere BUT to the first position (under certain parent nodes with the same attribute value).

I could simply cancel the dropping event - but that would confuse the user: All other checks are done in nodeDragging and if the drop target is invalid the not-allowed cursor style is displayed. This should also be the case when this certain node type is dragged directly under the certain parent nodes if this has no other children or above the first child of these parents.

So how can I determine the current dropPosition in the dragging event?

1 Answer, 1 is accepted

Sort by
0
Sebastian P.R. Gingter
Top achievements
Rank 2
answered on 30 Dec 2010, 03:52 PM
Got it myself.
The treeview holds this information in it's inner state:

var tree = this.get_navigationTree();
var e = args.get_domEvent();
 
// determine target node and position from underlying tree:
var destinationNode = (e.target == tree._dropClue)
   ? tree._dropClue.treeNode
   : tree._extractNodeFromDomElement(e.target);
 
var position = tree._draggingPosition;

I just hope that this internal implementation doesn't change on some updates.
Tags
TreeView
Asked by
Sebastian P.R. Gingter
Top achievements
Rank 2
Answers by
Sebastian P.R. Gingter
Top achievements
Rank 2
Share this question
or