How to disable SuggestBox in GWT
I am using SuggestBox to let user to select values. But however when there is only one value in the list, I am setting the value in the SuggestBox and I want this field to be non-editable.
I am trying below things, but now the component is not visible on UI.
sgstBox.getTextBox().setEnabl开发者_高级运维ed(false);
this is not working either
sgstBox.getTextBox().setReadOnly(true);
Two not tested solutions found on Google groups:
public static void setEnabled(SuggestBox sb,boolean enabled) {
DOM.setElementPropertyBoolean(sb.getElement(), "disabled", !enabled);
}
and
//pass in your own TextBox when you construct the SB:
TextBox tb = new TextBox();
SuggestBox sb = new SuggestBox(oracle, tb);
//...and later disable the TextBox:
tb.setEnabled(false);
精彩评论