PDA

View Full Version : [FIXED][2.x/3.x] AllowContainerDrop not fixed



Deadmeat
4 May 2009, 6:35 AM
Issue is exactly the same as described here.

http://extjs.com/forum/showthread.php?p=293667

Basically allowContainerDrop doesn't work because TreeDropZone only covers the tree elements and not the tree container. For reasons that I don't understand, TreeDragZone covers the entire container rather than just the tree elements. This seems backwards to me.

Obligatory examples here:

vanilla (http://www.users.on.net/~clear/ext3/allowContainerDrop_test_normal.html)

patched (http://www.users.on.net/~clear/ext3/allowContainerDrop_test_hacked.html)

vtswingkid
5 May 2009, 5:52 AM
Please fix in 2.x also.

Deadmeat
12 May 2009, 3:23 AM
It's pretty easy to fix this yourself.

I don't know what side effects this has but all you need to do is change these lines:



Ext.tree.TreeDropZone.superclass.constructor.call(this, tree.getTreeEl(), config);




Ext.tree.TreeDragZone.superclass.constructor.call(this, tree.innerCt, config);


You still need to implement your own onContainerDrop and onContainerOver functions inside the drop zone:

I use something like this (goes in a custom TreeDropZone):



// allowContainerDrop that appends to the root node
onContainerDrop : function(dd, e, data) {
if (this.allowContainerDrop && this.isValidDropPoint({ ddel: this.tree.getRootNode().ui.elNode, node: this.tree.getRootNode() }, "append", dd, e, data)) {
var targetNode = this.tree.getRootNode();
targetNode.ui.startDrop();
var dropNode = data.node || (dd.getTreeNode ? dd.getTreeNode(data, targetNode, "append", e) : null);
var dropEvent = {
tree : this.tree,
target: targetNode,
data: data,
point: "append",
source: dd,
rawEvent: e,
dropNode: dropNode,
cancel: !dropNode,
dropStatus: false
};
var retval = this.tree.fireEvent("beforenodedrop", dropEvent);
if(retval === false || dropEvent.cancel === true || !dropEvent.dropNode){
targetNode.ui.endDrop();
return dropEvent.dropStatus;
}

targetNode = dropEvent.target;
if(!targetNode.isExpanded()){
targetNode.expand(false, null, function(){
this.completeDrop(dropEvent);
}.createDelegate(this));
}else{
this.completeDrop(dropEvent);
}
return true;
}
return false;
},

// allowContainerDrop that attempts to append to the root node
onContainerOver : function(dd, e, data) {
if (this.allowContainerDrop && this.isValidDropPoint({ ddel: this.tree.getRootNode().ui.elNode, node: this.tree.getRootNode() }, "append", dd, e, data)) {
return this.dropAllowed;
}
return this.dropNotAllowed;
}


It'd be nice to see both of these standard in TreeDropZone.

Hope this is useful.

evant
12 May 2009, 7:11 AM
From memory this fix caused other issues. I'll have a look into it again.

Deadmeat
12 May 2009, 6:43 PM
I wondered about that when it didn't show up in the re 3.0rc.

Any chance you could post what you find out.

I'm using a modified version of 2.2.1 and I'd be interested in what to look for.

vtswingkid
13 May 2009, 4:13 AM
I have been using it in 2.2.1 also, and have not noticed anything out of the ordinary.

evant
17 May 2009, 4:51 PM
Fixed in SVN, it's basically what you have but I removed some duplicated code.

Deadmeat
17 May 2009, 5:20 PM
Cool thanks. Will check it out.