gwt suggestBox如何获取其中的文本、值对
我需要一个自动建议组合框来显示不明确的字符串列表。但每个字符串都有一个唯一的 id。需要这个 id 才能知道用户选择了什么(将 id 发送回服务器并用它做一些事情)。
如何使用 gwt 的自动建议组合框“suggestionBox”来实现这一点。有没有办法将 id->name 对列表(如 listBox.addItem(String name, String value))获取到 suggestBox 中? 可能是通过覆盖建议Oracle? (如何获取所选名称的所选 id?)
或者这个用例最好由另一个 gwt 小部件实现吗?
提前谢谢
i need a autosuggest combobox for an ambiguous list of strings. but everey string has an unique id. this id is needed to know what the user has selected (send id back to server and do something with it).
how to implement this with the gwt's auto-suggest-comboBox "suggestionBox". Is there a way to get an List of id->name pairs (like with listBox.addItem(String name, String value)) into the suggestionBox?
probably by overwriting suggestionOracle? (how to get the selected id of the selected name?)
or is this usecase better be implemented by another gwt widget?
thx in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您想要子类化 SuggestionOracle。您还希望将 Suggestion 子类化为可以保存您需要的 id 的子类。
然后你的建议预言机将给出 StringWithIdSuggestion 实例,你可以将其转换为访问 getId();
Yep, you want to subclass SuggestionOracle. You also want to subclass Suggestion, to something that can hold the id you need.
Then your suggestion oracle will give StringWithIdSuggestion instances, which you can cast for access to getId();