3

我在 GWT 中使用SuggestBox来创建一个带有很好建议列表的文本框,如下所示:

public void onModuleLoad() {
    MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();  
    oracle.add("Cat");
    oracle.add("Dog");
    oracle.add("Horse");
    oracle.add("Canary");
    SuggestBox box = new SuggestBox(oracle);
    RootPanel.get().add(box);
    }
}

问题是我希望建议列表出现在文本框的顶部,而不是底部。

有没有办法做到这一点?

如果没有,GWT 中是否有任何替代 SuggestBox 的方法?(我成功地配置了 jQuery 的自动完成小部件以显示在文本框的顶部,但将其与 GWT 集成似乎既不优雅也不高效......)

谢谢!

4

1 回答 1

3

I don't think that there is any built-in way to do that, but I think it could be done with a little bit of work. SuggestBox has a constructor that takes a SuggestionDisplay as parameter. So you could subclass DefaultSuggestionDisplay and override its showSuggestions() method to display the popup where you want.

于 2012-07-04T20:50:14.380 回答