PDA

View Full Version : How can make an item draggable in MVC pattern?



Rasta1462
8 Nov 2013, 12:47 AM
Hi,
I am trying to have drag and drop on an item that create in MVC pattern, here is my sample code,it dose not work because the 'elements' on container in null , and it's not have data when the afterRender work, i try to fire 'readyview' but it's not solve the problem. the connection between model and store and data and controller is Ok. My question is how can I have drag and drop icon ?

code :
Ext.Loader.setPath({
'Ux':'app/Ux'
});
Ext.application({
name: 'AM',




autoCreateViewport: true,


controllers: [
'Users'
]
});

controller :
Ext.define('AM.controller.Users', {
extend: 'Ext.app.Controller',


stores: [
'[email protected]'
],


models: [
'[email protected]'
],


views: [
'[email protected]'
],


refs: [
{
ref: 'usersPanel',
selector: 'panel'
}
],




init: function() {
this.control(
{
});
this.callParent(arguments);
}


});

Ext.define('AM.view.user.List' ,{
extend: 'Ext.view.View',
alias : 'widget.userlist',
deferInitialRefresh: true,
title : 'All Users',
store: {type:'users'},


itemSelector: 'ux-desktop-shortcut',


tpl:[
'<p>HI EXTJS</p>',
'<tpl for=".">',
'<div style="margin-bottom: 10px;" class="ux-desktop-shortcut" id="shortcut-{id}">',
'<img src="{src}" />',
'<br/><span>{name}</span>',
'</div>',
'</tpl>'
].join(''),


afterRender:function(){
var me = this,container;
this.callParent(arguments);
container = Ext.get(me.el.id).select('div.ux-desktop-shortcut');
debugger;
Ext.each(container.elements, function(el) {
var dd = Ext.create('Ux.dd.DD', el.id, 'invoicesDnDGroup', {
isTarget : false
});
});
}


});

ettavolt
9 Nov 2013, 7:25 AM
You should better extend 'Ext.dd.DragSource' - it handles any number elements without additional rebinding.

Rasta1462
26 Nov 2013, 1:27 AM
Thanks ettavolt (http://www.sencha.com/forum/member.php?316440-ettavolt) , but I solve it . my new problem is drag and drop dos'n work on IE.