1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    77
    Answers
    6
    Vote Rating
    2
    azamatoak is on a distinguished road

      0  

    Default Unanswered: Listpaging with offset value instead of page number

    Unanswered: Listpaging with offset value instead of page number


    I am using listpaging plugin on a list and would like to use it with an 'offset' value. The API that I'm running against doesn't support pagination with 'page' values but rather uses offsets.

    If I have a limit of 10 and offset 0, I will get the first 10 records, with limit 10 and offset 10, I will get records 11-20 and so on.

    The listpaging plugin though requires a 'page' value. I have tried setting the startParam to 'offset' on my store proxy but this results in loading records 1-11 rather than 11-20.

    Any suggestions?

    Code:
    Ext.define('MyApp.store.Retailers', {
    	extend: 'Ext.data.Store',
    
    
    	config: {
    		storeId: 'retailersStore',
    		model: 'MyApp.model.Retailer',
            pageSize: 10,
            proxy: {
                type: 'ajax',
                method: 'GET',
                url: 'myapp/api/retailers',
                startParam: 'offset',
                reader: {
                    type: 'json',
                    rootProperty: 'data.entries',
                    totalProperty: 'count'
                }
            }
        }
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,027
    Answers
    3493
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    So you want to change what is displayed? When sending the request, there should be 3 params that are sent: page, start, limit
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jun 2013
    Posts
    45
    Answers
    1
    Vote Rating
    4
    AdamMarshall is on a distinguished road

      0  

    Default


    I'm finding that the initial request sends the start, limit and page params.

    Then subsequent requests only send the page param.


    The store:

    Code:
    Ext.define('Core.store.SearchResults', {    
        extend: 'Ext.data.Store',    
        config: {    
            autoLoad: false,            
            autoPaging: true,            
            clearOnPageLoad: false,            
            model: 'Core.model.SearchResult',            
            pageSize: 5,            
            proxy: {                
                type: 'ajax',                            
                url: Core.config.Constants.getSearchUrl(),                            
                reader: {                                
                    type: 'json'                                            
                },                                        
                startParam: 0,                                        
                limitParam: 5,                                        
                extraParams: {                
                    q: ''                                        
                }                                    
            }   
        }
    });
    The list:
    Code:
    Ext.define('Core.view.Search', {    
        extend: 'Ext.List',        
        xtype: 'search',        
        config: {            
            ...            
            plugins: [{                
                xclass: 'Ext.plugin.ListPaging',                
                autoPaging: true            
            }],            
            infinite: true        
        }
    });
    Last edited by AdamMarshall; 19 Aug 2013 at 1:47 AM. Reason: formatting code

  4. #4
    Sencha User
    Join Date
    Jun 2013
    Posts
    45
    Answers
    1
    Vote Rating
    4
    AdamMarshall is on a distinguished road

      0  

    Default


    Ah rubbish, solved my problem, was incorrectly defining startParam and limitParam
    Code:
    startParam: 'start', 
    limitParam: 'limit',