开发者

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); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜