1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    1
    Vote Rating
    0
    r4226 is on a distinguished road

      0  

    Question Unanswered: Local memory paging with a grid - MemoryProxy - Need Help

    Unanswered: Local memory paging with a grid - MemoryProxy - Need Help


    Hi,

    I'm trying to add pagination to a grid. I have all the data from the server stored locally in a ListStore but I'm having trouble setting up the PagingToolBar. It is probably a simple solution but I can't find any examples using Ext GWT 3.X local (not RPC) ListStores and paginations. Here's what I have:

    Code:
    // data_store = new ListStore<Person>...
    MemoryProxy<PagingLoadConfig, PagingLoadResult<Person>> proxy = new MemoryProxy<PagingLoadConfig, PagingLoadResult<Person>>(data_store);
    PagingLoader<PagingLoadConfig, PagingLoadResult<Person>> loader = new     PagingLoader<PagingLoadConfig, PagingLoadResult<Person>>(proxy);
    final PagingToolBar pagingToolBar = new PagingToolBar(30);
    pagingToolBar.getElement().getStyle().setProperty("borderBottom", "none");
    pagingToolBar.bind(loader);
    Thanks in advance.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Answers
    109
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    The basic problem you will have with the MemoryProxy is that it always returns the same data. Try subclassing MemoryProxy and overriding load so it returns the subset of the list you want. Here is a quick (untested) example of how this might look

    Code:
    public class MyPagingMemoryProxy extends MemoryProxy<PagingLoadConfig, PagingLoadResult<Person>> {
      private final List<Person> totalList;
      public MyPagingMemoryProxy(List<Person> totalList) {
        super(null);//data is useless in this case, memoryProxy only designed to hold, not to search
        this.totalList = totalList;
      }
      @Override
      public void load(PagingLoadConfig config, Callback<PagingLoadResult<Person>, Throwable> callback) {
        List<Person> results = totalList.subList(...);// Get results list based on the data the proxy was created with
        
        callback.onSuccess(new PagingLoadResultBean<Person>(results, ...));// again, data from the config
      }
    }
    You may want to add a call to onFailure if the config didn't make sense.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    1
    Vote Rating
    0
    deeku24 is on a distinguished road

      0  

    Default This saved me lot of time, i was trying to implement MemoryProxy, then saw your code.

    This saved me lot of time, i was trying to implement MemoryProxy, then saw your code.


    Thanks for the input regarding the MemeoryProxy. Especially the detail "data is useless in this case, memoryProxy only designed to hold, not to search"

Thread Participants: 2