Unanswered: GXT Layouts initially wrong and not responding to browser re-size
I've found that none of the Sencha layouts are working correctly for me. The layout on initial page open is roughly correct, but nothing responds to changes in browser size.
As a simple test I've constructed a new Eclipse project (zztest) which just opens the Sencha CenterLayoutExample class. This works fine when viewing it as part of the overall Sencha demonstration (running from a web server on my own machine).
But in this simple test the CenterLayout widget opens up displayed in the horizontal center, but near the top. There is no response to browser re-size.
Watching with Firebug, no positions are changed on any of the elements as the browser size is changed (On the Sencha example the positioning values are re-calculated as the browser changes size).
It appears as if the browser.resize() event is not being passed to the layout system.
In brief my configuration is:
Host page starts with: <!DOCTYPE html>
Inherits in xxtest.gwt.xmk: <inherits name='com.google.gwt.user.User'/>
The file war/zztest/reset.css is in place.
The gxt-3.0.1.jar is referenced both from the Java Build Path and the launch configuration.
I am not using Maven.
Can anyone see anything missing / wrong?
I solved my own problem.
The set-up was OK.
I needed to wrap the CenterLayoutExample in a Viewport. That responds to the browser re-size events.
This is correct - wrapping the root layout in a Viewport will ensure that this root always knows how much space it has to work with within the browser. For this reason, you should never have more than one viewport (they will each take all of the available space).
All of the demos at sencha.com/examples implement entrypoint, but they are shown by implementing IsWidget, not by calling that onModuleLoad method. Most of them work just fine when added directly to the page as they have a specific size already, but some should have a Viewport, including the CenterLayoutExample. I'll look into updating the examples to ensure that their layout always runs correctly when set up as a standalone example.
Tags for this Thread