Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fires event after Drag & Drop on TreePanel

Tags:

panel

extjs

How can I use Ext.tree.ViewDDPlugin's events?

I have a TreePanel that uses DDPplugin, but I'd like to know how to listen to the drop event.

This is what my code looks like:

var monPretree = Ext.create('Ext.tree.Panel',{
            id : 'treepanel',
            title : 'TITRE',
            //width : 800,
            //height : 600,
            width : 500,
            enableDD: true,
            useArrows : true,
            viewConfig : {
                plugins : {
                    ptype: 'treeviewdragdrop',     
                      appendOnly: true,     
                      listeners: {       
                        drop: function (node, data, overModel, dropPosition) {         
                              alert('CHANGE');       
                        },       
                        notifyDrop: function (dragSource, event, data) {         
                              var nodeId = data.node.id;         
                              alert(nodeId);       
                        },       
                        notifyOver: function (dragSource, event, data) {         
                            alert('over');
                        }     
                    }   
                }

            },
            singleExpand : false,
            store : monPrestore,
            rootVisible : false,

I would like to fire drop events for example, but my code doesn't work

Thanks :)

like image 931
Vincent Guesné Avatar asked Dec 28 '22 19:12

Vincent Guesné


1 Answers

I've got same question and found this page.

There is note in documentation, in event section: "This event is fired through the TreeView. Add listeners to the TreeView object"

I've tryed to found method in tree.Panel class to get view, unsuccessfully. So, all you need to do, just put listners block in configuration to viewConfig section (not in plugin section):

viewConfig : {
                plugins : {
                    ptype: 'treeviewdragdrop',     
                    ...
                },
                listeners: {       
                        drop: function (node, data, overModel, dropPosition) {         
                              alert('CHANGE');       
                        },         
                    }   
                }

            },

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.tree.plugin.TreeViewDragDrop-event-drop

like image 107
Anton Avatar answered Jan 14 '23 11:01

Anton