1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    62
    Vote Rating
    5
    s.t.a.s is on a distinguished road

      0  

    Default "List Paging" loses some records in list

    "List Paging" loses some records in list


    The problem is in the subject. I'm using plugin List Paging for my list. All was Ok until I decided to check data in list. And I've found that after the next page was loaded some records was absent. For example, I have pageSize = 10, but when I expect 20 records I see only 17.
    I have checked store, but it has all 20 records and it looks like there is a bug in list or list paging plugin.

    Model
    Code:
    Ext.define('MyApp.model.MyModel', {
        idProperty: 'Id',
        extend: 'Ext.data.Model',
        alias: 'model.MyModel',
        config: {
            fields: [{ name: 'Id', type: 'auto'},
                     { name: 'Name', type: 'string'},
                     { name: 'Phone', type: 'string'}  
                    ]
        }
    });
    Store
    Code:
    Ext.define('MyApp.store.MyJsonStore', {
        extend: 'Ext.data.Store',
        requires: [
            'MyApp.model.MyModel'
        ],
    
    
        config: {
            model: 'MyApp.model.MyModel',
            storeId: 'MyJsonStore',
            
            autoLoad: false,
            clearOnPageLoad: true,
            pageSize: 10,
    
    
            proxy: {
                type: 'ajax',
                headers: {
                    'Accept': 'application/json',
                    'Authorization': 'Basic ' + Ext.util.base64.encode('TestUser:UserPass')
                },
                url: 'http://localhost:2376/WebApp/0/ServiceModel/EntityDataService.svc/AccountCollection?$select=Id,Name,Phone',
                reader: {
                    type: 'json',
                    rootProperty: 'd.results'
                }
            }
        }
    });
    On beforeload I set some extra parameters for my web service (including my page parameters)
    Code:
    var store = Ext.getStore('MyJsonStore');
    store.on('beforeload', onBeforeLoadStore);
    Function onBeforeLoadStore
    Code:
    function onBeforeLoadStore(store, operation, options) {
        if (toResetCurrentPage) {
            store.currentPage = 1;
        }
        var currentPage = store.currentPage;
        var previousRecords = (currentPage > 1) ? (currentPage - 1) * 10 : 0;
        store.getProxy().setExtraParam("$top", 10);
        store.getProxy().setExtraParam("$skip", previousRecords);
        if (toResetCurrentPage) {
            toResetCurrentPage = false;
        }
    }
    When I made one change in ListPaging.js (took it SDK) the list showd 19 records (and it's not a solution at all), but I can't understand where it had lost record. Here is this change:
    Code:
    loadNextPage: function() {
    	var store = this.getList().getStore();
    
    
            this.setLoading(true);
    
    
            //keep a cache of the current scroll position as we'll need to reset it after the List is
            //updated with new data
            this.scrollY = this.getScroller().position.y;
    
    
    	store.nextPage({ addRecords: true });
    	this.getList().refresh();
        }
    Please, help!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,095
    Vote Rating
    855
    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


    We don't load the store, we use operation to load new records. This way we don't need to refresh the list, just update what needs to be updated.
    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
    Jan 2012
    Posts
    62
    Vote Rating
    5
    s.t.a.s is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    We don't load the store, we use operation to load new records. This way we don't need to refresh the list, just update what needs to be updated.
    But how to update? And what event I should use for it?
    Honestly, I thought store.nextPage() in ListPaging does it automatically. And it looks like it really does but incorrectly in my case.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,095
    Vote Rating
    855
    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


    I'm sorry. I got my threads mixed up, I had another thread asking about the PullRefresh plugin which my reply was meant for
    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.

  5. #5
    Sencha User
    Join Date
    Jan 2012
    Posts
    62
    Vote Rating
    5
    s.t.a.s is on a distinguished road

      0  

    Default



  6. #6
    Sencha User
    Join Date
    Jan 2012
    Posts
    62
    Vote Rating
    5
    s.t.a.s is on a distinguished road

      0  

    Default Ideas?

    Ideas?


    Any ideas? Has anybody faced with it?

  7. #7
    Sencha User
    Join Date
    Jan 2012
    Posts
    62
    Vote Rating
    5
    s.t.a.s is on a distinguished road

      0  

    Default Ideas?

    Ideas?


    Any ideas? Has anybody faced with it?

  8. #8
    Sencha User
    Join Date
    Apr 2012
    Posts
    6
    Vote Rating
    1
    tarun_juneja@hotmail.com is on a distinguished road

      0  

    Default


    add below override in a js file and load it after plugin file also remove on before load...that is not required

    Ext.override(Ext.plugin.ListPaging, {
    loadNextPage: function () {

    var store = this.getList().getStore();


    // add all proxy param here again
    store.getProxy().setExtraParam('source', '');

    this.setLoading(true);
    //keep a cache of the current scroll position as we'll need to reset it after the List is
    //updated with new data
    this.scrollY = this.getScroller().position.y;
    store.nextPage({ addRecords: true });

    }
    });

  9. #9
    Sencha User
    Join Date
    Feb 2012
    Posts
    54
    Vote Rating
    0
    Rui Marinho is on a distinguished road

      0  

    Default


    Did u get this working?

    looks you are handling a odata feed.. i m using that too..
    wouldn't be asier to just use the next link that's in the feed?

  10. #10
    Sencha User
    Join Date
    Jan 2012
    Posts
    62
    Vote Rating
    5
    s.t.a.s is on a distinguished road

      0  

    Default I solved it

    I solved it


    Yeah, I solved it. It was totally my fault. I added some extra divs for list items behind them, thats why ListPaging counted different numbers of shown elements on the page.

    >>
    wouldn't be asier to just use the next link that's in the feed?
    Frankly speaking, I don't know how to parse odata correctly using store.proxy (I mean how to get "next" link). If you have a code, it would be great.