How do I use ComboBox in EXT-GWT with 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?
How to use EXT-GWT ComboBox
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");
Maksim,
I am not sure whether it helps you or not. It was based on the GWT-EXT for combobox. As I remember that, it wraps the String[] with SimpleStore object.
//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 ?
// create store
ListStore<String> store = new ListStore<String>();
store.add( Arrays.asList( new String[]{"A","B","C"}));
ComboBox cb = new ComboBox();
cb.setStore(store);
Thanks for your response. There is something is wrong with SimpleStore object. It does not exist. I think it is no longer exist in this library. –
Fussy
I believe that the ComboBox in Ext-GWT API has setStore(ListStore) function to load data. so we can use as below:(It might be the same as the demo example ) // create store ListStore<String> store = new ListStore<String>(); store.add( Arrays.asList( new String[]{"A","B","C"})); ComboBox cb = new ComboBox(); cb.setStore(store); I hope it helps. –
Mccrary
Now it complains about String in "ListStore<String>", here is error "Bound mismatch: The type String is not a valid substitute for the bounded parameter <M extends ModelData> of the type ListStore<M>" –
Fussy
© 2022 - 2024 — McMap. All rights reserved.