Search code examples
gxt

How to trigger BorderLayoutContainer center ContentPanel to resize when other regions collapse/expand?


I would like the BorderLayoutContainer Center region Content Panel to fill to the available space when the other regions collapse/expend.

Right now, the center region moves to the collapsed space but does not resize.


Solution

  • I've figured this out from a bunch of digging thru the api, source, and hints in the Sencha forums.

    My setup is a center BorderLayoutContainer ContentPanel with a MPV View Composite VerticalLayoutContainer surrounding two Toolbars and a Grid.

    The issue is the toolbars and grid would not resize to fill the space when the center ContentPanel resized.

    My solution is for the View VerticalLayoutContainer Composite to implement the HasLayout interface and to add a ResizeHandler() to the surrounding ContentPanel.

    centerContentPanel.addResizeHandler( new ResizeHandler() {
    
    @Override
    public void onResize(ResizeEvent event) {
        Widget w = centerContentPanel.getWidget();
        if (w instanceof HasLayout) {
            ((HasLayout) w).forceLayout();
        }
      }
    });