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,640
    Answers
    107
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      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

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar