Help required with SuggestBox

13 views
Skip to first unread message

Gugle

unread,
Oct 7, 2007, 1:51:44 AM10/7/07
to Google Web Toolkit
Hi all,
I need some help for getting SuggestBox to behave the way I want.
Currently, SuggestBox displays the matching strings only after a user
has entered some text. But I want it to show all the options available
in the drop down as soon as the user clicks inside the SuggestBox and
then filter the contents of the dropdown as and when the user enters
text. I don't see any way of doing this with the current SuggestBox. I
can't even subclass SuggestBox since it is declared final. Can someone
tell me how I can make it display all the items in the drop down as
soon as it receives focus? Any ideas would be very much appreaciated.

Thanks in advance!

Sanjiv Jivan

unread,
Oct 7, 2007, 3:16:44 PM10/7/07
to Google-We...@googlegroups.com
You could try using the ComboBox of GWT-Ext. The showcase demo below has examples of it along with the relevant code (see the 'Source' tab).

http://gwt-ext.googlecode.com/svn/trunk/site/samples/Showcase/www/com.gwtext.sample.showcase.Showcase/Showcase.html

Sanjiv

Nathan Williams

unread,
Oct 8, 2007, 11:26:26 PM10/8/07
to Google Web Toolkit
SuggestBox won't ask its oracle for suggestions if the length of the
text in the composed TextBox is 0.

If you don't mind breaking encapsulation, you can force your way
around this by calling the private showSuggestions method through
JSNI:

public static native void showSuggestions(SuggestBox sb) /*-{

sb.@com.google.gwt.user.client.ui.SuggestBox::showSuggestions(Ljava/
lang/String;)("");
}-*/;

But even with this hack, you're still at the mercy the SuggestOracle.
If the implementation you're using ignores blank queries (as
MultiWordSuggestOracle does), then you still won't get any results.

In the end, as Sanjiv suggested, you're probably better off going with
a different widget.

Gugle

unread,
Oct 12, 2007, 5:52:57 AM10/12/07
to Google Web Toolkit
Thanx a lot for your suggestions guys.

On Oct 9, 8:26 am, Nathan Williams <nlwil...@gmail.com> wrote:
> SuggestBox won't ask its oracle for suggestions if the length of the
> text in the composed TextBox is 0.
>
> If you don't mind breaking encapsulation, you can force your way
> around this by calling the private showSuggestions method through
> JSNI:
>
> public static native void showSuggestions(SuggestBox sb) /*-{
>

> s...@com.google.gwt.user.client.ui.SuggestBox::showSuggestions(Ljava/

Reply all
Reply to author
Forward
0 new messages