如何在GWT建议框中隐藏建议? [英] How to hide suggestions in GWT SuggestBox?

查看:92
本文介绍了如何在GWT建议框中隐藏建议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GWT 2.4.我有一个建议箱",在某些情况下我需要隐藏建议列表.上下文如下.

I am using GWT 2.4. I have a Suggestbox and I have a requirement to hide the suggestion list under certain cases. The context is as below.

用户从建议列表中选择一个建议后,我将填充另外两个文本框字段,并使用与该选择相对应的值.例如,假设建议框包含用户名,并且用户从建议中选择一个用户名,然后在其他两个文本框中填充其他两个字段,例如用户地址和电子邮件.这两个字段现在只读.然后,用户单击编辑"按钮.现在,用户可以编辑用户名(即在建议框中编辑),用户地址和电子邮件.当用户编辑用户名时,再次显示建议是没有意义的,因为用户已经选择了用户并决定对其进行编辑.简而言之,我的SuggesBox应该表现为普通的文本框.我尝试了以下代码((不知道hideSuggestionList()已弃用)),但无法正常工作.

After user selects a suggestion from suggestion list, I am populating two other text box fields, with values corresponding to the selection. For example, suppose the suggestbox contains user-names, and user selects a user-name from suggestions, then other two fields, say user address and email are populated in two other text boxes. These two fields are read only now. Then user clicks on an 'Edit' button. Now the user can edit either user- name ( ie edit in suggestion box), user address and email. It doesn't make sense to show the suggestions again when the user is editing the user-name, since the user has already selected the user and decided to edit it. In a nutshell my SuggesBox should behave as a normal text box. I tried following code, (I know hideSuggestionList() is deprecated) but its not working.

display.getSuggestBox().hideSuggestionList();

阅读有关hideSuggestionList()的Javadoc,据说,已过时.请改用DefaultSuggestionDisplay.hideSuggestions()".我不知道如何使用DefaultSuggestionDisplay,并且将"SuggestBox"与"MultiWordSuggestOracle"结合使用.

Reading the javadoc for hideSuggestionList() it is said that, "Deprecated. use DefaultSuggestionDisplay.hideSuggestions() instead". I don't know how to use DefaultSuggestionDisplay, and I'm using SuggestBox with 'MultiWordSuggestOracle'.

感谢您的帮助!

推荐答案

您可以做的就是,当用户单击编辑"时,将"SuggestationBox"与普通的文本框"交换,然后在关闭"时返回.另外,因为如果您要隐藏建议列表,它仍然会从服务器中查询.通过交换小部件,您不必担心副作用. SuggestionBox本身也使用了一个TextBox,因此对于用户而言,该窗口小部件已更改是不可见的.

What you can do is simply swap the SuggestionBox with a normal TextBox when the user clicks edit and back when edit is closed. Also because if you would hide the suggestions list, it still queried from the server. By swapping the widget you don't have to care about side effects. SuggestionBox itself uses also a TextBox and thus for the user it's not visible the widget has changed.

这篇关于如何在GWT建议框中隐藏建议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆