Hi guys,
I'm playing with GXT 1.1 and ComboBox with TypeAhead enabled. I already got something working (ComboBox + ListStore + BaseListLoader + HttpProxy + JsonReader) however I have a few questions:
1. Who is responsible for filtering the list of available values in ComboBox when user starts typing the leading characters? Let's assume that ComboBox has 100 initial values. When user types first two or three characters, how to filter out the values that do not match those first letters and narrow down the selection to for example 20 remaining values?
I can the ComboBox API has methods like: setTriggerAction(), doQuery(), setAllQuery(), setTypeAhead(), setTypeAheadDelay() etc. but how to use all of that? I must admit, documentation/JavaDoc is not great in this respect...
2. I noticed that ComboBox loader/reader sends a lot of requests to my backend that produces the JSON data with query parameters like this:
Code:
?sortDir=NONE&sortDir=NONE&start=0&limit=0
or
Code:
?sortDir=NONE&sortDir=NONE&start=0&limit=0&sortDir=NONE&start=0&limit=0
or
Code:
?sortDir=NONE&sortDir=NONE&start=0&limit=0&sortDir=NONE&start=0&limit=0&sortDir=NONE&start=0&limit=0&sortDir=NONE&start=0&limit=0&sortDir=NONE&start=0&limit=0&sortDir=NONE&start=0&limit=0
Sometimes the list of query parameters gets pretty long. Why's that? How to disable that? I don't need any paging or limits there... Also I played with ComboBox.setAllQuery() but I didn't make it work, I never saw my query actually included in the request. Any ideas how to work with that?
3. Also I noticed that when I start typing into the ComboBox, the ComboBox immediately replaces the first characters I typed with the first value from the list...isn't it strange?
For example the list has values: Apple, Banana, Orange (in this order) and when I start typing "Oran", the combo box replaced it with "Appl" and "e" (last character in Apple) is highlighted - see attached screenshot.
4. Does anybody have any working example of ComboBox with TypeAhead and any reader/proxy? If so, can you post it here?
Thanks a lot.
Here is my combo box code:
Code:
ModelType type = new ModelType();
type.root = "fruit";
type.id = "id";
type.addField("label");
type.addField("price");
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "fruit");
HttpProxy<ModelData, ListLoadResult<ModelData>> proxy = new HttpProxy<ModelData, ListLoadResult<ModelData>>(builder);
JsonReader<ModelData> reader = new JsonReader<ModelData>(type);
ListLoader loader = new BaseListLoader(proxy, reader);
ListStore<ModelData> store = new ListStore<ModelData>(loader);
ComboBox<ModelData> combo = new ComboBox<ModelData>();
combo.setDisplayField("label");
combo.setFieldLabel("id");
combo.setStore(store);
combo.setHideTrigger(true);
combo.setTypeAhead(true);
combo.setMinChars(1);
And JSON data:
Code:
{
"fruit" : [
{"id":1, "label":"Apple", "price":"$1/lb"},
{"id":2, "label":"Banana", "price":"$2/lb"},
{"id":3, "label":"Orange", "price":"$3/lb"},
{"id":4, "label":"Peach", "price":"$4/lb"}
]
}