0

I'm working with Ext GWT. I have a grid with paging and JSON.

I don't understand, Where do i can set all records number in the paging config.

My paging grid is wrong, bacause it doesn't know, how much records in the database's table.

Thx

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);
user1485841
  • 31
  • 1
  • 6

1 Answers1

1

Your total count should come in your request response, and will be part of the PagingLoadResult. I typically do not use any readers, so I have to create my own PagingLoadResult, which is when you will pass in the total count. Typically, I will use a RpcProxy, forego using any readers and do the heavy lifting of putting the PagingLoadResult together inside the 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) {
                }

}
Jonathan
  • 705
  • 5
  • 16