PDA

View Full Version : Get viewConfig Events in controller



pixman
13 Jul 2012, 2:09 AM
Hello,
in my treePanel i have implement the treeviewdragdrop Plugin.

I listen the events 'drop' and 'beforedrop' in the viewConfig declaration, like this :


Ext.define('BKOFF.view.filemanager.FolderTree', { extend: 'Ext.tree.Panel',
alias : 'widget.foldersTree',
title: 'Folders',
animate: true,


viewConfig: {
plugins: [{
ptype: 'treeviewdragdrop'
}],
toggleOnDblClick: false,
listeners: {
beforedrop: function () { console.log('beforedrop', arguments); },
drop: function () { console.log('drop', arguments); }
}
},

But i want keep all my code in the controller.
How make the same listenning like this, only in the controller ?

If it's not possible, can it's possible to 'bubble' the event to the controller ?

Thanks

sword-it
13 Jul 2012, 2:17 AM
HI!

yo may try to use custom events and may fire them according to your needs.




Ext.extend(Ext.Panel, {
initComponent:function() {
// parent init component
yourClass.superclass.initComponent.apply(this, arguments);
// add custom events
this.addEvents('sampleEvent');
}
,sampleEventing:function(arg1, arg2) {
// fire custom event
this.fireEvent('sampleEvent', scope, arg1, arg2);
}
...



here is the tutorial for you from Saki:-
http://blog.extjs.eu/know-how/events-explained/comment-page-1/

redraid
13 Jul 2012, 2:40 AM
this.control({
'foldersTree dataview': {
beforedrop: function () { console.log('beforedrop', arguments)},
drop: function () { console.log('drop', arguments);}
}
});

pixman
13 Jul 2012, 2:57 AM
this.control({
'foldersTree dataview': {
beforedrop: function () { console.log('beforedrop', arguments)},
drop: function () { console.log('drop', arguments);}
}
});


I have test the same code but quering view in place of dataview.

Thanks a lot for your help :-)