【问题标题】:How to set a textbox value with the selected value of Bootstrap Typeahead?如何使用 Bootstrap Typeahead 的选定值设置文本框值?
【发布时间】:2024-01-13 17:16:01
【问题描述】:

我有以下 gwt-bootstrap ui.xml :

<b:Typeahead ui:field="typeahead">
   <b:TextBox ui:field="searchBox" searchQuery="true"
     placeholder="Search..." />
</b:Typeahead>

如何以编程方式获取预先输入项的建议响应“单击时”并将其设置为文本进入搜索框?

【问题讨论】:

    标签: gwt uibinder gwt-bootstrap


    【解决方案1】:

    好吧,Adarsha 答案在我的情况下并没有真正起作用,因为我使用的是完整的 gwt。所以我的解决方案是:

    typeahead.setUpdaterCallback(new Typeahead.UpdaterCallback() {
    
            @Override
            public String onSelection(Suggestion selectedSuggestion) {
                String text = selectedSuggestion.getDisplayString();
                return null;
            }
        });
    

    【讨论】:

      【解决方案2】:

      下面的链接一定会对你有所帮助 -

      Get selected items value for Bootstrap's typeahead

      一旦获得选定的值,只需执行 textbox.setValue(value)。

      【讨论】: