java 如何使用 EXT-GWT 组合框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1161796/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use EXT-GWT ComboBox
提问by Maksim
How do I use ComboBox in EXT-GWTwith static data. For example I just want to hard code (for demo purposes) list of First Names and display it to the user. I don't want to use any dummy objects that they are using in their samples. Where can I find simple example with Strings?
如何在带有静态数据的EXT-GWT 中使用 ComboBox 。例如,我只想硬编码(出于演示目的)名字列表并将其显示给用户。我不想使用他们在样本中使用的任何虚拟对象。我在哪里可以找到字符串的简单示例?
采纳答案by KevMo
Here is the code I use in my project:
这是我在项目中使用的代码:
SimpleComboBox combo = new SimpleComboBox();
combo.add("One");
combo.add("Two");
combo.add("Three");
combo.setSimpleValue("Two");
回答by Tiger
Maksim,
马克西姆,
I am not sure whether it helps you or not. It was based on the GWT-EXTfor combobox. As I remember that, it wraps the String[] with SimpleStore object.
我不确定它是否对你有帮助。它基于组合框的GWT-EXT。我记得,它用 SimpleStore 对象包装 String[] 。
//create a Store using local array data
final Store store = new SimpleStore(new String[]{"abbr", "state", "nick"}, getStates());
store.load();
final ComboBox cb = new ComboBox();
cb.setForceSelection(true);
cb.setMinChars(1);
cb.setFieldLabel("State");
cb.setStore(store);
cb.setDisplayField("state");
cb.setMode(ComboBox.LOCAL);
cb.setTriggerAction(ComboBox.ALL);
cb.setEmptyText("Enter state");
cb.setLoadingText("Searching...");
cb.setTypeAhead(true);
cb.setSelectOnFocus(true);
cb.setWidth(200);
I hope it helps. Tiger
我希望它有帮助。老虎
ps) Did you try this example ?
ps)你试过这个例子吗?
// create store
ListStore<String> store = new ListStore<String>();
store.add( Arrays.asList( new String[]{"A","B","C"}));
ComboBox cb = new ComboBox();
cb.setStore(store);

