| Issue 444: | Read auto allocated node key after drop | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Regarding node DND: When a node drop is complete I need to access the unique key value automatically assigned to the dropped node in the target tree.
I note that the key value is available on the onDrop event as it turns up in the following:
var dict = $("#tree2").dynatree("getTree").toDict();
alert("Sending: " + JSON.stringify(dict));
I can't find an answer to this question in any of the forums. Is this because it is not yet a feature?
Jul 16, 2013
To clarify: This solution worked for me because I actually needed the parent key to populate a relational database. This method would not get the dropped node key if the node was dropped with hit mode "over" on a node that had children. You wouldn't know which of the children had just been dropped. So I guess the problem still remains.
Jul 20, 2013
Just curious: if the keys are important to you, why don't you assign them yourself instead of letting dynatree generate arbitrary ones?
Status:
Waiting
Labels: Milestone-Release1.2.5
Sep 7, 2013
(No comment was entered for this change.)
Status:
WontFix
|
Hi. I solved my problem with this code (as part of the onDrop event) but it seems like a bit of a cluge. Is there a better way? onDrop: function(node, sourceNode, hitMode, ui, draggable) { /**This function MUST be defined to enable dropping of items on the tree. * sourceNode may be null, if it is a non-Dynatree droppable. */ // ... // Find the dropped node's parent and get the parent's key // if (hitMode == "over") { // The dropped node was dropped on this node so this node IS the parent var droppedNodeParentKey = node.data.key; } else { // The dropped node was dropped either before or after the node. // The dropped node is therefore a sibling of node so: // the dropped node's parent is node's parent var droppedNodeParent = node.getParent(); // get the sibling's parent var droppedNodeParentKey = droppedNodeParent.data.key; } alert("Parent key: " + droppedNodeParentKey); }