使用 EXT-GWT 组合框
我扩展 ComboBox
并在构造函数中具有这样的代码:
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");
结果:ajax 查询发送到服务器但在组合框中看不到结果,但是当单击它时它会再次加载数据然后显示它,以及如何将值设置为组合框?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我创建了一个简单的商店工厂方法,应该可以解决您的问题。
复制您的类并创建商店:
代码中的错误是您向 ModelType 添加了两个字段,而您应该只添加一个字段,其中“id”作为值,“name”作为显示
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