View Full Version : Where is the nodeDragOver tree event hiding ?

26 Aug 2011, 6:45 AM

I am looking for a way to control the tree drag to allow/deny node drop according to custom logic.

In Ext3, it was possible to use the "nodedragover" event to do that but it does not seem to exist anymore.
The "beforedrop" event isn't what I'm looking for because I want the icon beside the dragged element to change according the fact the drop is allowed or not (which was the purpose of nodeDragOver).

I think I have to override the Ext.tree.ViewDropZone.notifyEnter method but I don't know how to configure it through the Ext.tree.plugin.TreeViewDragDrop plugin configuration.

Thanks for any help :)

29 Aug 2011, 12:41 AM
Looking inside Ext code, I found this :

Ext.define('Ext.tree.ViewDropZone', {
extend: 'Ext.view.DropZone',
isValidDropPoint : function(node, position, dragZone, e, data) {
// @TODO: fire some event to notify that there is a valid drop possible for the node you're dragging
// Yes: this.fireViewEvent(blah....) fires an event through the owning View.
return true;

I have overloaded the prototype of this class replacing the TODO comment by

if(this.view.fireEvent('dragover', node, position, dragZone, e, data) === false) {
return false;
and I can now handle my custom logic through the 'dragover' event listener

Though is sounds too easy to be honest and I wonder why this TODO was left over, so is there anything wrong with this ?


31 Aug 2011, 1:37 PM
In your JSON, set allowDrag to false or true.

I found it using firebug. Although the treeviewdragdrop plugin uses enableDrag and enableDrop, In firebug I saw allowDrag and allowDrop being used.

I passed those in my PHP JSON and their values as variables and was able to control what gets dragged in the tree.

In the API, allowDrag is listed under NodeInterface.

1 Sep 2011, 4:08 AM

Thanks for the answer, it definitely helped.
I used the "draggable" property in Ext3, and it's now become "allowDrag" and I thank you to point it out for me.

Though it did not solved all the problem as I cannot write all my D&D logic server side.

Anyway I finally decided to extend the existing TreeViewDragDrop plugin and other classes, overloading some method of the dragzone and dropzone to fit my needs.

It's quite sad that all the previous flexibility of native drag/drop classes has not been exposed in Ext4 like it was before.

The only thing I am afraid of is the following comment found in the doc of classes I inherit from

NOTE This is a private utility class for internal use by the framework. Don't rely on its existence.