-
17 Jun 2011 8:14 AM #1
FitLayout and 100% height
FitLayout and 100% height
Hi,
I have a problem when trying to apply a 100% height to a widget (a LayoutContainer in this case).
This LayoutContainer has a FitLayout layout and it's contained in a GWT widget with a height of 100% (depending on the window height).
Since the parent widget has no layout, I've fixed its height at 100%.
Now I have a FitLayouted LayoutContainer ^^ with a height of 100%.
Step 1 : success !
Now I want to add a simple ContentPanel in this LayoutContainer.
According to the documentation, the ContentPanel should take the size of the layout's container, i.e. 100%.
But that takes 100 pixels invariably.
Step 2 : fail !
2 questions :
- Is that problem due to the fact that I specified height in percent and not in pixels ?
- Is there a workaround ? (bonus : is it not recommended to mix GWT and GXT items ?)
Another one : why 100 pixels ??
Here is an piece of the source :
Thanks !Code:public class MyWidget extends LayoutContainer { protected void onRender(final Element target, final int index) { super.onRender(target, index); FitLayout layout = new FitLayout(); setHeight("100%"); setLayout(layout); ContentPanel cp = new ContentPanel(); add(cp); } }
-
17 Jun 2011 8:26 AM #2
Instead of setting a size by hand, especially when using percentage sizes, you should use the layoutsystem to size your widgets. Were do you add your MyWidget class? Why do you wrap a ContentPanel inside a LayoutContainer with a FitLayout?
-
18 Jun 2011 6:57 AM #3
No, the parent widget is not a LayoutContainer neither a ContentPanel, it's a GWT Composite... so I can't use the layout system.
And that's why a asked this question : is it not recommended to mix GWT and GXT items ?
I agree with you, including a ContentPanel inside a LayoutContainer with a FitLayout is simply . In fact, the goal is to include a west and a center region with a BorderLayout... the ContentPanel simplifies the problem.
I tried to replace FitLayout directly with a BorderLayout but it doesn't work : even if the BorderLayout is "100% capable", the included ContentPanels (for west and center region) take no height when I specify nothing, and 100px when I specify 100% !
I thought GXT was able to resize widgets inside pure GWT widgets but obivious it can't (.


Reply With Quote