Results 1 to 2 of 2

Thread: JSON, Paging and Memory Proxy

  1. #1
    ExtJS Premium Member
    Join Date
    Feb 2010
    Location
    Neptune Beach, Florida
    Posts
    51

    Default JSON, Paging and Memory Proxy

    Hopefully, this will save others time in the dubugger!

    When implementing Paging with JsonReader and MemoryProxy it turns out that the JSONReader needs it's "createReturnData" method overridden so that it returns a PagingLoadResult<ModelData> instead of simply an List<ModelData> which is the natural method result type. This is the expected generics type for the BasePagingLoader loader implementation, which will cause class cast problems if not overridden.


    Code:
            jsonReader = new JsonReader<PagingLoadResult<ModelData>>(modelType) {
                @Override
                protected Object createReturnData(Object loadConfig, List<ModelData> records, int totalCount) {
                    PagingLoadResult<ModelData> md = new BasePagingLoadResult<ModelData>(records,0,totalCount);
                    if(loadConfig!=null && loadConfig instanceof PagingLoadConfig){
                        int off = ((PagingLoadConfig)loadConfig).getOffset();
                        md.setOffset(off);
                    }
                    return md;
                }
            };
            PagingModelMemoryProxy proxy = new PagingModelMemoryProxy(responseText);
            loader = new BasePagingLoader<PagingLoadResult<ModelData>>(proxy,jsonReader);
            loader.setRemoteSort(true);
            pagingToolBar.bind(loader);
    (If their is a more appropriate way to do this, please let me know)

  2. #2
    ExtJS Premium Member
    Join Date
    Feb 2010
    Location
    Neptune Beach, Florida
    Posts
    51

    Default JsonPagingLoadResultReader

    It seems I missed the JsonPagingLoadResultReader, which uses pretty much the same overrides (but better!).
    There exists an illustrative example in the Buffered Grid example source code.

Similar Threads

  1. memory proxy with paging not displayed properly
    By Rajalakshmi_j in forum Ext 3.x: Help & Discussion
    Replies: 20
    Last Post: 22 Jul 2009, 3:50 AM
  2. Dynamic Grid without Using Paging; Paging Memory Proxy
    By deitch in forum Ext 2.x: User Extensions and Plugins
    Replies: 29
    Last Post: 23 Jun 2009, 10:04 AM
  3. [SOLVED]Paging Memory Proxy + SoapProxy + Grid Paging Help
    By josh803316 in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 21 Feb 2009, 11:48 AM
  4. Memory proxy with paging and group summary
    By roberthenniger in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 3 Nov 2008, 5:11 AM
  5. Memory Proxy to Combo problem
    By deanoj in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 9 May 2008, 3:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •