PDA

View Full Version : Panel / Mixed Collection - how to chage order of contained components



nugatto
27 Sep 2009, 6:24 AM
Hi all,
I'm building a panel containing a lot of other smaller panels. I would like it to have ability to change order of the panels inside. How to achieve this the easiest way?
I tried doing something like that:


var removed = container.remove(cmpToMove);
container.insert(toIndex, removed);

That solution gives me a lot of problems, because all the handlers attached to my elements are gone with removed dom nodes.
Can someone point me in good direction? Thanks

hendricd
27 Sep 2009, 9:28 AM
var removed = container.remove(cmpToMove, false);

nugatto
27 Sep 2009, 9:49 AM
Thanks hendricd for quick response, but this still doesn't work. The remove method does not remove anything with that extra parameter. Strange :/

hendricd
27 Sep 2009, 10:52 AM
Thanks hendricd for quick response, but this still doesn't work. The remove method does not remove anything with that extra parameter. Strange :/

Post some more of your layout. Let's see what's goin' on here. ;)

nugatto
28 Sep 2009, 12:06 PM
Ok, so I made simplest example for my code equivalent:



var container = new Ext.Panel({
renderTo: 'container',
title: 'container',
items: [{
xtype: 'panel',
title: 'panel 1',
html: 'panel 1 content'
},{
xtype: 'panel',
title: 'panel 2',
html: 'panel 2 content'
}],
buttons: [{
text: 'move item',
handler: function(){
var container = this.ownerCt.ownerCt;
var cmpToMove = container.items.get(0);
var removed = container.remove(cmpToMove, false);
container.insert(1, removed);
container.doLayout();
console.log('component moved: ', cmpToMove.title);
}
}]
});


Clicking on the button repeatedly shows me "panel 1" and "panel 2" on console, so it must be working fine. The problem is that I can't see any results - the doLayout method is not working or what? :/

nugatto
29 Sep 2009, 12:59 AM
Anybody please?