I extend ComboBox and in constructor have such code:
ModelType type = new ModelType();
type.setRoot("data");
type.addField("id", "id");
type.addField("name", "name");
JsonLoadResultReader<ListLoadResult<ModelData>> reader = new JsonLoadResultReader<ListLoadResult<ModelData>>(type);
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "/category/getall");
HttpProxy<String> proxy = new HttpProxy<String>(builder);
BaseListLoader<ListLoadResult<ModelData>> loader = new BaseListLoader<ListLoadResult<ModelData>>(proxy, reader);
ListStore<ModelData> store = new ListStore<ModelData>(loader);
setStore(store);
loader.load();
setValueField("id");
setDisplayField("name");
setName("categoty");
Result: ajax query send to server but no results see in combobox but when click on it it loads data again and then display it, and how to set value to combobox?
I’ve created a simple store factory method that should solve your issue.
Copy in your class and create the store:
the error in your code is that you add two fields to the ModelType, instead you should add just one field with “id” as value and “name” as display