//String url = "http://extjs.com/forum/topics-remote.php";
String url = "http://localhost:9090/mobiledoc/jsp/get-remote.jsp";
ScriptTagProxy<Object, PagingLoadResult<ModelData>> proxy = new ScriptTagProxy<Object, PagingLoadResult<ModelData>>(url);
ModelType type = new ModelType();
type.root = "topics";
type.totalName = "totalCount";
type.addField("title", "topic_title");
type.addField("topicId", "topic_id");
type.addField("author", "author");
type.addField("excerpt", "post_text");
DataField date = new DataField("lastPost", "post_time");
date.type = Date.class;
date.format = "timestamp";
type.addField(date);
JsonReader<PagingLoadConfig> reader = new JsonReader<PagingLoadConfig>(type) {
@Override
protected ListLoadResult newLoadResult(PagingLoadConfig loadConfig, List<ModelData> models) {
PagingLoadResult result = new BasePagingLoadResult(models, loadConfig.getOffset(),loadConfig.getLimit());
return result;
}
};
PagingLoader loader = new BasePagingLoader(proxy, reader);
ListStore<ModelData> store = new ListStore<ModelData>(loader);
ComboBox<ModelData> combo = new ComboBox<ModelData>();
combo.setWidth(580);
combo.setDisplayField("title");
combo.setItemSelector("div.search-item");
combo.setTemplate(getTemplate());
combo.setStore(store);
combo.setHideTrigger(true);
combo.setPageSize(10);
VerticalPanel vp = new VerticalPanel();
vp.setSpacing(10);
vp.add(combo);