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?
+1
A:
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);
Tiger
2009-07-21 22:07:38
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.
Maksim
2009-07-22 00:26:03
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 storeListStore<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.
Tiger
2009-07-22 04:53:35
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>"
Maksim
2009-07-22 15:26:00