PDA

View Full Version : JSON Paging doesnot work



thihy
23 Aug 2009, 10:10 AM
Problem Description
When I try to use JSON Paging Feature and press the "NEXT" button, the browser can send the request very well, but the page number doesn't change. For example, the current page number is 1, but it will be still 1 after I press "NEXT".
GXT version
2.0.1
Sample code


RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
GWT.getHostPageBaseURL() + urlpath);

HttpProxy<String> proxy = new HttpProxy<String>(builder);
JsonPagingLoadResultReader<PagingLoadResult<ModelData>> reader = new
JsonPagingLoadResultReader<PagingLoadResult<ModelData>>(type);

final PagingLoader<PagingLoadResult<ModelData>> loader = new
BasePagingLoader<PagingLoadResult<ModelData>>( proxy, reader);

final PagingToolBar toolBar = new PagingToolBar(20);
toolBar.bind(loader);

ListStore<ModelData> store = new ListStore<ModelData>(loader);
final Grid<ModelData> grid = new Grid<ModelData>(store, cm);
...

Cause
In "JsonPagingLoadResultReader.java", I find the method


protected BasePagingLoadResult<ModelData> newLoadResult(Object loadConfig, List<ModelData> models) {
return new BasePagingLoadResult<ModelData>(models);
}

Variable loadConfig is not used。

In "PagingToolBar.java", there is a method


protected void onLoad(LoadEvent event) {
if (!rendered) {
renderEvent = event;
return;
}
config = (PagingLoadConfig) event.getConfig();
PagingLoadResult<?> result = event.getData(); //result is the returned result of newLoadResult。
start = result.getOffset();// will be always ZERO.

sven
23 Aug 2009, 10:16 AM
This is already adressed in SVN. You will need to override that method to fit your needs.