PDA

View Full Version : How to manage drag event in 'treeviewdragdrop' plugin



csanchezr85
6 Mar 2013, 5:10 AM
Hello,

I would like to manage the drag event (before or on) when I drag an item from a tree. This tree has configured a viewConfig as this:


viewConfig = {
plugins: {
ptype: 'treeviewdragdrop',
pluginId: this.dndPluginId,
appendOnly: this.appendOnly,
enableDrag: true,
enableDrop: true,
nodeHighlightOnDrop: true,
nodeHighlightOnRepair: true,
nodeHighlightColor: _self.nodeHighlightColor
},
listeners: {
beforedrop: {
fn: function (node, data, overModel, dropPosition, dropHandler, eOpts) {
if (_self.beforedrop) {
_self.beforedrop(_self, node, data, overModel, dropPosition, dropHandler, eOpts);
}
}
},
drop: {
fn: function (node, data, overModel, dropPosition, eOpts) {
if (_self.drop) {
_self.drop(_self, node, data, overModel, dropPosition, eOpts);
}
}
}
}
};

But the 'beforedrop' and 'drop' events don't are useful for me: what I want is exactly manage the drag of the item! I have been searching a solution in the forum and in other sources, but it seems that is impossible to manage the dragging of the tree item.

Really, there is no way to manage any drag event for the 'treeviewdragdrop' plugin?

Thanks in advance.

mitchellsimoens
8 Mar 2013, 7:09 AM
You can add it via:


Ext.define('Override.tree.ViewDragZone', {
override : 'Ext.tree.ViewDragZone',

onDrag : function(e) {
this.view.fireEvent('drag', this.view, this, e);

this.callParent([e]);
}
});

Now you have a drag event on the tree view (not the plugin). You can modify the arguments but right now it is the view, the Ext.tree.ViewDragZone, and the event passed to onDrag.

csanchezr85
11 Mar 2013, 12:11 AM
Hello, thanks for your answer! It's just what I was looking for. It seems to be an easy solution, but I was really very frustrated of proving other code...Thanks!