View Full Version : Gxt widgets do not resize with the browser window
1 Nov 2011, 12:56 AM
I have recently built up a view using gxt grids and fieldsets etc.
I have used gxt containers for these, such as contentpanel and layoutcontainers, however everything is managed in the context of GWT2 MVP, with a GWT simplepanel on the top.
Now what I've seen is that the widgets do not resize when I resize the browser window. Anyone having any idea whether that is possible? I have set properties such as autoWidth on the widgets, but they only work on initial rendering, not on window resizing.
I am puzzled, is resizing of GXT widgets running within the GWT mvp framework supposed to work out?
1 Nov 2011, 2:19 PM
Setting autoWidth rarely makes layout work better - instead, try make your root element in the layout tree a Viewport, and adding that to the RootPanel.
autoWidth allows the browser's css and html rendering to deal with all sizing, whereas GXT's layout system measures the available space and instructs widgets how much room they have to work with. To properly size all widgets to the browser, a Viewport must be attached to the root of the page and given a layout - containers added to that viewport often require layouts that will size their children.
Each of the layout classes will say in its javadocs if it will size and position its children - use that to guide you when selecting layouts to use based on how you want the container's children to be set up.
2 Nov 2011, 1:44 PM
Using a ViewPort on the top solved the problem of automatic resizing of containers within it.
I still have a problem with a EditorGrid not resizing and filling up its parent container on browser resize though. I assume its a matter of adjusting the container layouts perhaps.
2 Nov 2011, 2:44 PM
If the Grid isn't resizing, then it's parent (or its parent's parent...) doesn't have a layout set that will size its children.
It often helps to think of layouts as a tree, usually starting at the top with a Viewport. If any node in the tree doesn't have a layout that will size its children, then from there on down, sizes will not be applied dynamically. This can be the desired behavior: it can allow you to force something to be too big and require scrollbars, but in cases like the grid, it usually isn't what you want.
3 Nov 2011, 10:43 AM
Just tried replacing a couple of GWT panels that existed in the container tree, replaced with GXT containers and used AnchorLayouts, and setting percentage sizes.
It worked like a charm. The grid now resizes with the browses as all other components. The autoWidth/Height properties actually made things all the worse.
Thanks alot for the help!
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.