1. #1
    Sencha User
    Join Date
    Oct 2009
    Posts
    7
    Answers
    1
    Vote Rating
    0
    guymage is on a distinguished road

      0  

    Default Answered: PagingModelMemoryProxy equivalent ?

    Answered: PagingModelMemoryProxy equivalent ?


    Hi,

    I'm migrating my Sencha application from 2.x to 3.0.1
    I have a grid wich can containes 20-30 rows, no needs to have a complex paging with request, I used a PagingModelMemoryProxy.

    In 3.0.1, this object does not exists anymore, what is its equivalent ?

    I tried to understand this example:
    http://www.sencha.com/examples/#Exam...calstoragegrid
    But not sure that is the same goal

  2. The solution was in this thread:
    http://www.sencha.com/forum/showthre...roxy-Need-Help

    A create this class to manage my local pagination

    Code:
    public class PagingMemoryProxy<T> extends MemoryProxy<PagingLoadConfig, PagingLoadResult<T>> {
    
        private final List<T> totalList;
    
        public PagingMemoryProxy(List<T> 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 loadConfig, Callback<PagingLoadResult<T>, Throwable> callback) {
            // Get results list based on the data the proxy was created with
            int limit = loadConfig.getOffset() + loadConfig.getLimit();
            if (totalList.isEmpty()) {
                limit = 0;
            } else if (limit >= totalList.size()) {
                limit = totalList.size() - 1;
            }
            List<T> results = totalList.subList(loadConfig.getOffset(), limit);
    
            PagingLoadResultBean<T> bean = new PagingLoadResultBean<T>(results, totalList.size(), loadConfig.getOffset());
            callback.onSuccess(bean);
        }
    
    }

  3. #2
    Sencha User
    Join Date
    Oct 2009
    Posts
    7
    Answers
    1
    Vote Rating
    0
    guymage is on a distinguished road

      0  

    Default


    MemoryProxy seems to be the one.

    But I did not find a good example, any idea ?

    Thanks

  4. #3
    Sencha User
    Join Date
    Oct 2009
    Posts
    7
    Answers
    1
    Vote Rating
    0
    guymage is on a distinguished road

      0  

    Default


    The solution was in this thread:
    http://www.sencha.com/forum/showthre...roxy-Need-Help

    A create this class to manage my local pagination

    Code:
    public class PagingMemoryProxy<T> extends MemoryProxy<PagingLoadConfig, PagingLoadResult<T>> {
    
        private final List<T> totalList;
    
        public PagingMemoryProxy(List<T> 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 loadConfig, Callback<PagingLoadResult<T>, Throwable> callback) {
            // Get results list based on the data the proxy was created with
            int limit = loadConfig.getOffset() + loadConfig.getLimit();
            if (totalList.isEmpty()) {
                limit = 0;
            } else if (limit >= totalList.size()) {
                limit = totalList.size() - 1;
            }
            List<T> results = totalList.subList(loadConfig.getOffset(), limit);
    
            PagingLoadResultBean<T> bean = new PagingLoadResultBean<T>(results, totalList.size(), loadConfig.getOffset());
            callback.onSuccess(bean);
        }
    
    }

  5. #4
    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


    Consider not extending MemoryProxy, and just implementing DataProxy, since you aren't using the superclass at all - this will let you skip the super(null) call.

    Also think about having a setItems call so that you can refresh from the server if needed, and adding sort/filter operations (if needed) before the subList takes place. This should be at worst no worse than doing it in the store, but with many items operations like this might be too expensive to do on the client.

  6. #5
    Sencha User
    Join Date
    Oct 2009
    Posts
    7
    Answers
    1
    Vote Rating
    0
    guymage is on a distinguished road

      0  

    Default


    Thanks for the advice

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."