I am trying to embedding a GXT container into a "slot" whose size is variable. It works if you resize the window larger but not if you resize it smaller. Below is the sample code Darrel provided. I used the Explore demo as my test. I created a new Viewport class does the same thing as the below DelayedTask which worked just fine in Beta 2/3.
snippet from Darrell:
There is no problem embedding a GXT container into a "slot" whose size is variable. I created some test code to demonstrate.
I started with this HTML (note the nested div with relative positioning which is needed for BorderLayout):
<table height="100%" width="100%" border="0"> <tr> <td height="25%" width="100%">top</td> </tr> <tr> <td height="50%" width="100%"> <div id="slot1" style="width:100%;height:100%;position:relative"></div> </td> </tr> <tr> <td height="25%" width="100%">bottom</td> </tr></table>
There are 3 rows. The top and bottom are 25% tall, the middle is 50% tall. The goal is to add a GXT container to the center row and give it a BorderLayout.
Here is the code I ended up with:
public void onModuleLoad() { Window.enableScrolling(false); final LayoutContainer c = new LayoutContainer(); c.setSize("100%", "100%"); c.setLayout(new BorderLayout()); c.setBorders(true); ContentPanel center = new ContentPanel(); center.setHeading("Center"); BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER); centerData.setMargins(new Margins(5, 5, 5, 0)); c.add(center, centerData); ContentPanel west = new ContentPanel(); west.setHeading("West"); BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 200); westData.setMargins(new Margins(5, 5, 5, 5)); c.add(west, westData); final DelayedTask task = new DelayedTask(new Listener<BaseEvent>() { public void handleEvent(BaseEvent be) { El td = c.el().getParent(); c.setSize(td.getWidth(), td.getHeight()); } }); Window.addWindowResizeListener(new WindowResizeListener() { public void onWindowResized(int width, int height) { task.delay(200); } }); RootPanel.get("slot1").add(c); }Thanks - Scott.