我正在使用 Ext GWT。我有一个带有分页和 JSON 的网格。
我不明白,我在哪里可以在分页配置中设置所有记录数量。
我的分页网格是错误的,因为它不知道数据库表中有多少记录。
谢谢
String path = GWT.getHostPageBaseURL() + (Examples.isExplorer() ? "" : "../../" ) + "backend/index.php?action=getLines";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);
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(10);
toolBar.bind(loader);
loader.load(0, 10);
您的总计数应出现在您的请求响应中,并将成为 PagingLoadResult 的一部分。我通常不使用任何读取器,因此我必须创建自己的 PagingLoadResult,此时您将传入总计数。通常,我会使用 RpcProxy,放弃使用任何读取器,并完成将 PagingLoadResult 放在 RpcProxy 内的繁重工作。
@Override
public void load(PagingLoadConfig loadConfig,
final AsyncCallback<PagingLoadResult<?>> callback) {
[some async service call](..., new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
// Get info from your result and construct paged result
PagingLoadResult<?> pagedResult = new ...
callback.onSuccess(pagedResult)
}
@Override
public void onFailure(Throwable caught) {
}
}