如何在Gwt中将html应用于SuggestList弹出窗口? 我想在建议列表弹出窗口中应用html表。
例如:
private SuggestOracle getSuggest() {
oracle = new MultiWordSuggestOracle();
oracle.add("<table border=1><tr><td>hussain</td></tr><td>hussain1</td></table>");
oracle.add("<table border=1><tr><td>taher</td></tr><td>taher1</td></table>");
oracle.add("<table border=1><tr><td>hussain22</td></tr><td>hussain2</td></table>");
return oracle;
}
弹出窗口应显示包含2列的表,但它将html作为文本 谢谢 侯赛因
答案 0 :(得分:0)
覆盖MultiWordSuggestOracle#isDisplayStringHTML()。
SuggestOracle.Suggestion显示字符串应该被视为HTML吗?如果是真的,这一切建议都是&#39;显示字符串将被解释为HTML,否则将被解释为文本。
MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(){
@Override
public boolean isDisplayStringHTML(){
return true;
}
};
注意:每个建议都有一个显示字符串和一个替换字符串。
有关详细信息,请查看SuggestOracle.Suggestion
- 编辑 -
有关详细信息,请查看MultiWordSuggestOracle and HTML display
完整的示例代码:
MultiWordSuggestOracle oracle = new MultiWordSuggestOracle() {
@Override
public boolean isDisplayStringHTML() {
return true;
}
};
Collection<Suggestion> suggestionList = new ArrayList<Suggestion>();
suggestionList.add(new MultiWordSuggestOracle.MultiWordSuggestion("hussain",
"<table border='1'><tr><td>hussain</td></tr></table>"));
suggestionList.add(new MultiWordSuggestOracle.MultiWordSuggestion("taher1",
"<table border='1'><tr><td>taher1</td></tr></table>"));
suggestionList.add(new MultiWordSuggestOracle.MultiWordSuggestion("hussain2",
"<table border='1'><tr><td>hussain2</td></tr></table>"));
oracle.setDefaultSuggestions(suggestionList);