PDA

View Full Version : DropTarget on MixedCollection Item



jasondeegan
26 Mar 2012, 4:36 PM
Ladies & Gents,

Thanks in advance for your help. I'd like to drop a grid row (single shown column) on to one of 9 different mixedCollection items within a panel. I'm struggling with understanding what I'm doing wrong and despite searching I can't find a solution that fits my problem. Here's the code:



var cardsColumns = [{
header: "cardId", dataIndex: 'cardId', hidden:true }, {
header: "Card Vendor", sortable: false, dataIndex: 'cardVendor', hidden:true }, {
header: "Card Image", sortable: false, dataIndex:'cardImage', renderer:renderCard
}];
var cardsGrid = new Ext.grid.GridPanel({
title: 'Cards', id:'cardsGrid', store: cardsStore, columns:cardsColumns, region:'west', width:150, disableSelection:false, trackMouseOver:true, hideHeaders:false, enableHdMenu:true,
enableDrag:true
});

var cardsView = new Ext.Panel({
region:'center',
layout:{
type:'table',
columns:3
},
defaults:{
height:50, width:50
},
items : [{
id : 'panel1',
html : 'Panel 1'
}, {
id : 'panel2',
html : 'Panel 2'
}, {
id : 'panel3',
html : 'Panel 3'
}, {
id : 'panel4',
html : 'Panel 4'
}, {
id : 'panel5',
html : 'Panel 5'
}]
});

cardsView.on( "render", function(){
console.log( 'rendered' );
var dt1 = new Ext.dd.DropTarget( Ext.get( 'panel1' ), { /* I've also tried "Ext.getCmp" AND 'panel1' */
notifyDrop : function(dd, e, node, a) {
console.log(d, e, node, a);
}
});
});


On rendering the window (which these panels fit into), I get my console.log( 'render' ), but then I get a "this.el is null" error. I'm pretty sure it's referencing the red "Ext.get( 'panel1' )" code above, but for the life of me I can't figure out if it's a premature execution or other?

Jason

jasondeegan
26 Mar 2012, 4:46 PM
I updated the onRender function to this and got a different error:



cardsView.on( "render", function( panel ){
var dt1 = new Ext.dd.DropTarget( panel.items.items[0].body, {
notifyDrop : function(dd, e, node, a) {
console.log(d, e, node, a);
}
});
});


It doesn't render because the MixedCollection item isn't a panel with a body...hmmmm, and now I've reached my limit in understanding of how the MixedCollection Item differs from the panel and how to fix.