Nick Heiner
Nick Heiner

Reputation: 122580

GWT SuggestBox: Rich suggestions instead of just text?

GWT's SuggestBox shows a list of inputs that match what the user has already typed. Can the suggestion list items contain arbitrary HTML or widgets instead of just strings? For example, I'd like to show an icon with some suggested items.

Upvotes: 4

Views: 1183

Answers (1)

Will
Will

Reputation: 925

Simple answer - yes, the suggestions can contain arbitrary HTML - just put this in the suggestion implementation for your SuggestOracle. For example:

public class CountrySuggestion implements Suggestion {
  ..snip..
  @Override
  public String getDisplayString() {
    return "<i>" + country.getName() + "</i><img src='icon.png'>";
  }
}

Upvotes: 4

Related Questions