PDA

View Full Version : get the new 'parentNode' when using 'treeviewdragdrop'



noamway
31 Jan 2013, 3:45 AM
If a user is drag a node to a folder (parent) I try to get is new parent ID with the event 'DROP'.
The problem is that if the folder is not render I'm getting from:
node.parentNode.internalId
The main root of the tree.

But if I'm using "setTimeout" I'm getting is new parent ID.

This is what I have now, and I don't want to use the 'timeout', what option do I have:

listeners: {
'drop': {fn:function( node, data, overModel, dropPosition, eOpts ){
var moveID ;
var movePreviousSibling ;
var moveNextSibling ;
var moveParentNode ;

node = data.records[0];

if (node)
moveID = node.internalId ;

//Disable all the tree
Ext.getCmp('treePagesList').disable();

setTimeout(function(){
//Get all the detail of is new position
node = Ext.getCmp('treePagesList').getStore().getNodeById(moveID);

if (node.previousSibling)
movePreviousSibling = node.previousSibling.internalId ;

if (node.nextSibling)
moveNextSibling = node.nextSibling.internalId ;

if (node.parentNode)
moveParentNode = node.parentNode.internalId ;

}, 500);

}, scope:this}
}

noamway
7 Feb 2013, 12:33 AM
Can someone can help me here please?
I really like to know if there is any option do use more event like 'drop' that working Better.

Arg0n
7 Feb 2013, 1:26 PM
You could modify the Ext.tree.ViewDropZone (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.tree.ViewDropZone) class (source (http://docs.sencha.com/ext-js/4-1/source/ViewDropZone.html#Ext-tree-ViewDropZone)). There you have a function named: handleNodeDrop

When the function finished adding the new node, you could fire an event:



view.fireEvent('afternodedrop', node);


I made my own treeviewdragdrop plugin for that. It's the same plugin, it just uses my modified version of Ext.tree.ViewDropZone.

noamway
24 Feb 2013, 10:01 PM
You're great. Big thanks :-)