PDA

View Full Version : Dynamically add components to vbox



tomtom-
13 Dec 2009, 11:11 AM
Hi all,

I'm trying to add components to a container which layout is vboxlayout like this :



child1 = new Ext.Panel({ title: 'Child1', html: 'Child1' });

child2 = new Ext.Container({ title: 'Child2', layout: 'vbox' });

win = new Ext.Window({ height: 500, width:500, layout: 'hbox', items: [child1, child2] });
win.show();

child3 = new Ext.Panel({ title: 'Child3', html: 'Child3', flex: 1});

child2.add(child3);
child2.doLayout();


But I never see child3 !!
I noticed that if I give a size to this component, I can see it. But the size is dynamic that's the reason why I can't give one.

Anyone has an idea of my mistakes ?

Thanks,

Tom

30 Dec 2009, 8:09 AM
try the following:



child1 = new Ext.Panel({ title: 'Child1', html: 'Child1' });

child2 = new Ext.Container({ title: 'Child2', layout: 'vbox' });

win = new Ext.Window({ height: 500, width:500, layout: 'hbox', defaults:{flex:1, height : 100}, items: [child1, child2] });
win.show();

(function() {
child3 = new Ext.Panel({ title: 'Child3', html: 'Child3', flex: 1});

child2.add(child3);
child2.doLayout();
win.doLayout()
}).defer(100)