19 Jan 2009 1:44 PM #1
How to add CenterLayoutExample to Viewport
Let's say I've the following in my onModuleLoad():
Viewport vp = new Viewport();
CenterLayoutExample cle = new CenterLayoutExample();
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!
19 Jan 2009 1:51 PM #2
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);
19 Jan 2009 2:04 PM #3
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.
19 Jan 2009 2:07 PM #4Code:
19 Jan 2009 2:23 PM #5
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?
19 Jan 2009 2:25 PM #6
If you use FlowLayout you have to size the CenterLayoutExample:
19 Jan 2009 2:43 PM #7
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?