0

I'm developing an application using GWT 2.3.0 and GXT 2.2.5.

I've got a LayoutContainer with ScrollMode set to AUTO and layout set to RowLayout with a horizontal orientation. It's used as the display window for my application.

The problem is that when the browser is resized so that the vertical scrollbar is displayed, the contents do not resize to account for it, causing the horizontal scrollbar to also appear even if it's not needed.

Is there a way to have the layout account for the space taken up by the scrollbar when rendering the widgets?

NestorDRod
  • 166
  • 1
  • 14
  • Okay, I've partially discovered the answer after some research. RowLayout does have a method called setAdjustForScroll() that automatically resizes the contents to allow space for the scrollbar. Problem is that the method does it whether there is a scrollbar or not. So I still need a way to determine whether the scrollbar is present, whether it's because of the window resizing, or dynamic changes in the contained widgets. ScrollContainer does not have any events registered that are triggered by the scrollbar showing up, and I don't know what else I could use as a listener. – NestorDRod Oct 31 '12 at 17:52

1 Answers1

0

Ok that is a bit tricky to accomplise. I would do it like this: On the Entry point (so that you know it is always active) add a resize handler to the Window

Window.addResizeHandler(new ResizeHandler() {
    @Override
    public void onResize(ResizeEvent event) {
         // Fire Event containing the new size informing the application of the change
         // Or resize the Layout container
    }
}

If you choose to fire the event and you are using the MVP pattern then it is pretty simple to fire the event via the event bus and catch it wherever you like in the application.

The only catch here is that you might want to run the functions in onResize() inside a timer as in many cases the Window width/height reported have not the final value, due to the event being fired before the resizing completes.

Athanasios Kataras
  • 25,191
  • 4
  • 32
  • 61
  • So you're saying that I would have to implement a handler from scratch to calculate if the scrollbar will be displayed on resize and manually redefine the size of the contained widgets to account for it. That is the kind of functionality I would expect GXT to handle automatically. Very unsatisfactory. – NestorDRod Oct 29 '12 at 13:43
  • GXT has setAutoHeight(true) and setAutoWidth(true) for the LayoutContainer to resize, but it's contents is a totally different matter. – Athanasios Kataras Oct 29 '12 at 14:23