PDA

View Full Version : How to add CenterLayoutExample to Viewport



mkolb
19 Jan 2009, 1:44 PM
Let's say I've the following in my onModuleLoad():

Viewport vp = new Viewport();
CenterLayoutExample cle = new CenterLayoutExample();
???
vp.add(cle);
???
RootPanel.get("slot1").add(vp);

CenterLayoutExample is from http://extjs.com/examples/layouts/centerlayout.html

So what I need to do in place of question marks to get the example rendered in the center and middle of my browser window?
I've got it to work with gxt 1.2 but in gxt 1.2.1 I see nothing because there is always some div in it with height 0.
I've tried to set the height manually but it seems that I'm missing something because the special div doesn't change. Only the parent and the child divs.
Please point me in the right direction!
Thanks.
Markus

sven
19 Jan 2009, 1:51 PM
You cant use a viewport in your example, as you arent adding it to the body but to some other element with id "slot1".




CenterLayoutExample cle=new CenterLayoutExample();
cle.setSize(400, 600);
RootPanel.get("slot1").add(cle);

mkolb
19 Jan 2009, 2:04 PM
Hi Sven,
thanks for your patience. But it doesn't help me.
I can use RootPanel.get().add(vp) , too.
But I don't see anything.

I attach a new image where you can see the divs.

sven
19 Jan 2009, 2:07 PM
vp.setLayout(new FitLayout());

mkolb
19 Jan 2009, 2:23 PM
Ah, cool. That's it.
But I don't understand why vp.setLayout(new FlowLayout()); doesn't show anything at all.
The childs have size, so why do you need a FitLayout?
Is it because the "cle" is rendered/sized before the "vp" and vp has first height 0?

sven
19 Jan 2009, 2:25 PM
If you use FlowLayout you have to size the CenterLayoutExample:


cle.setSize(400, 600);

mkolb
19 Jan 2009, 2:43 PM
Ok. I think I've got it. I've tried some setSize at different places and now I understand what's going on.
Thanks for your help. Are you paid by Ext?