PDA

View Full Version : grid local paging



tassoc
15 Feb 2009, 10:16 AM
Hi guys,
looking at GWT samples, I found some examples of server side paging, but I didn't find anything about local paging.
Is it possible using the PagingToolbar component with data which are already on client side?
I see that paging tools assume that data are always requested to the server, using RPC calls.
Thanks in advance

Noggy
16 Feb 2009, 2:57 AM
If someone pulls this off, i could use it too :)

micgala
17 Feb 2009, 1:41 AM
I am also looking into this.

If someone knows how to use the Paginator for a store which has already all records, please let us know...

Thanks,
Michel.

chriswesdorp
17 Feb 2009, 4:57 AM
You could create a new class based on DataProxy (or MemoryProxy for that matter) and implement the load method to read the given load configuration (which will be a PagingLoadConfig) and return a subset of a locally stored list with entries for your grid. Then return a BasePagingLoadResult with the properties set for total list size, number of records in the result and the subset and the loader thinks is has received a fresh list of entries.

How you fill the local list is up to you, you can use the available communication methods (XML, JSON, GWT RPC) for this.

dpope22
17 Feb 2009, 1:47 PM
Here's what I did:


loader = new BasePagingLoader<BasePagingLoadConfig, BasePagingLoadResult<MyObject>>(null) {

@Override
protected void loadData(BasePagingLoadConfig config, AsyncCallback<BasePagingLoadResult<MyObject>> callback) {
callback.onSuccess(**This is where you implement your local paging);
}
};
loader.setRemoteSort(true);


You would have to supply a BasePagingLoadResult to the callback.onSuccess method call. It works perfectly for me. I get the entire list of data elements outside of the paging process, then, all paging occurs locally without going back to the server.

paco_online
2 Mar 2009, 1:41 AM
hi dpope22,

i am new in ext gwt - so so can you give a more detailed example, what is happening inside the loadData method.

thx
paco

dpope22
2 Mar 2009, 11:28 AM
On this line

callback.onSuccess(**This is where you implement your local paging);

you need to return a BasePagingLoadResult<YourObject> in the callback.onSuccess method.

The paging load config contains the sort information and the paging information from the grid and paging toolbar. All you need to is sort your objects based on those parameters.