GXT Paging Grid With Remote Search

I'm using paging grid in GXT to view a list.
The basic is shown below:

ScriptTagProxy<PagingLoadResult<ModelData>> proxy = new ScriptTagProxy<PagingLoadResult<ModelData>>(url);
JsonPagingLoadResultReader<PagingLoadResult<ModelData>> reader = new JsonPagingLoadResultReader<PagingLoadResult<ModelData>>(type);
final PagingLoader<PagingLoadResult<ModelData>> loader = new BasePagingLoader<PagingLoadResult<ModelData>>(proxy, reader);
loader.setRemoteSort(true);
final ListStore<ModelData> mystore = new ListStore<ModelData>(loader);
return mystore;


But I want to use the same paging component for remote search. Finally I came out with this solution.

private void searchStaff() {
String url = "index.php?option=com_model&model={0}&action=getStaffList";
PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0);
config.setLimit(50);

BasePagingLoader loader = ((BasePagingLoader) store.getLoader());
ScriptTagProxy proxy = (ScriptTagProxy) loader.getProxy();
if (keyword.getValue() == null || keyword.getValue().equals("")) {
} else {
url += "&keyword=" + keyword.getValue().toString();
}
url = url.replace("{0}", "Staff");
url = DataUtils.formatURL(url);
url = url.replaceAll("kpiwebgwt", "kpiweb");
proxy.setUrl(url);
store.getLoader().load(config);
}

0 comments:

 
Copyright © peyotest