How to add a scrollbar to a SuggestBox popup?

934 views
Skip to first unread message

googelybear

unread,
Mar 19, 2010, 1:54:18 PM3/19/10
to Google Web Toolkit
Hi,

I would like to display a scrollbar in the popup panel shown by the
SuggestBox (Imagine there might be 100 entries in the list and you
don't want to display a huuuge popup, instead you want to add a nice
vertical scrollbar to it). Does anyone know how to achieve this with
gwt 2.0?

I have found this thread from 2007 (it is not possible to reply
anymore to this):
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/b3f2c9a789967a7/857697210bdcda41?lnk=gst

But I cannot apply the solution to overwrite the gwt-SuggestBoxPopup
style and add 'overflow: scroll' anymore in GWT 2.0 as this gets
overwritten programmatically in the PopupPanel (e.g. in onstart() or
onComplete(): DOM.setStyleAttribute(curPanel.getElement(), "overflow",
"visible");) '

Also I cannot copy this class and modify it as it has many
dependencies (besides the obvious ugliness of this way).

Has anyone found a more proper solution for this problem?

thanks,

Dennis

Paul Stockley

unread,
Mar 19, 2010, 3:10:32 PM3/19/10
to Google Web Toolkit
Can't you just add a scrollPanel as the first child of the Popup?

googelybear

unread,
Apr 22, 2010, 9:31:29 AM4/22/10
to Google Web Toolkit
unfortunately not, as the popup is not exposed to the outside world:

<code>
private final PopupPanel suggestionPopup;
</code>

On Mar 19, 9:10 pm, Paul Stockley <pstockl...@gmail.com> wrote:
> Can't you justadda scrollPanel as the first child of thePopup?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Andy

unread,
Apr 22, 2010, 11:49:04 AM4/22/10
to Google Web Toolkit
We started using the trunk because of the refactoring that's been done
to SuggestBox. I considered copying it out and doing my own
refactoring but ran into the same dependency issues.

If you are able to use the trunk with the refactored SuggestBox, you
find that you can do the following:

public class CustomSuggestBox extends SuggestBox {

public static final class CustomSuggestionDisplay extends
DefaultSuggestionDisplay

@Override
protected Widget decorateSuggestionList(Widget suggestionList) {
// wrap it here
}

}

public CustomSuggestBox(Oracle oracle) {
super(oracle, new TextBox(), new CustomSuggestionDisplay());
}

}

If you don't feel comfortable using the trunk (I don't blame you), at
least you know that you'll eventually be able to do this.

I can't say for sure that adding a ScrollPanel in there will work. We
added a header and a footer to the dropdown and it worked well.

Eugene D

unread,
Apr 30, 2010, 6:15:05 AM4/30/10
to Google Web Toolkit
One solution I found is to stick with CSS but use !important to ensure
your styles don't get overridden programatically. For browsers that
support !important, this should behave like you want.

For instance:

.gwt-SuggestBoxPopup {
overflow-y: auto !important;
max-height: 250px;
Reply all
Reply to author
Forward
0 new messages