1. #1
    Sencha User
    Join Date
    Feb 2010
    Location
    Seattle, USA
    Posts
    19
    Vote Rating
    0
    gurpreet.saini is on a distinguished road

      0  

    Default PagingToolbar showing incorrect range of records

    PagingToolbar showing incorrect range of records


    I am working with PagingToolbar and found that the displayInfo/displayMsg shows the incorrect range of records. It adds 1 to the end. e.g. the following image shows that the grid is showing the range as 41 to 61 while it should show 41 to 60. And for the last page it shows 5641 to 5661 when the record count is 5660.

    [IMG]file:///C:/Documents%20and%20Settings/pj301d/Desktop/paging.jpg[/IMG]

    I am not sure if I am missing any bit of code. I can post the code too if required.

    Thanks
    -G
    Last edited by gurpreet.saini; 28 Feb 2011 at 12:26 PM. Reason: image

  2. #2
    Sencha User johnathanhebert's Avatar
    Join Date
    Apr 2008
    Posts
    77
    Vote Rating
    0
    johnathanhebert is on a distinguished road

      0  

    Default


    Can you post the server response data (json, xml, etc) for one "page" of data? You should have a "total" property in there somewhere that you are setting on the server. Are you sure that is being returned as 5660?
    Johnathan Hebert

  3. #3
    Sencha User
    Join Date
    Feb 2010
    Location
    Seattle, USA
    Posts
    19
    Vote Rating
    0
    gurpreet.saini is on a distinguished road

      0  

    Default


    Yes it is.

    {
    "totalCount": 5660,
    "tasksList": [.......]
    }

  4. #4
    Sencha User johnathanhebert's Avatar
    Join Date
    Apr 2008
    Posts
    77
    Vote Rating
    0
    johnathanhebert is on a distinguished road

      0  

    Default


    A quick look at PagingToolbar in the ExtJS source shows:

    Code:
    var msg = count == 0 ?
                    this.emptyMsg :
                    String.format(
                        this.displayMsg,
                        this.cursor+1, this.cursor+count, this.store.getTotalCount()
                    );
    in the Ext.PagingToolbar.updateInfo() (private) method... and the store.getTotalCount() method is returning the totalLength property of the store:

    Code:
        getTotalCount : function(){
            return this.totalLength || 0;
        },
    and store.totalLength is set in the store.loadRecords() (private) method depending on a condition, so I would check if you have add:true in your store config and if your start and limit parameters are passed to the server with the values you expect:
    Code:
            if(!options || options.add !== true){
                if(this.pruneModifiedRecords){
                    this.modified = [];
                }
                for(i = 0, len = r.length; i < len; i++){
                    r[i].join(this);
                }
                if(this.snapshot){
                    this.data = this.snapshot;
                    delete this.snapshot;
                }
                this.clearData();
                this.data.addAll(r);
                this.totalLength = t;
                this.applySort();
                this.fireEvent('datachanged', this);
            }else{
                var toAdd = [],
                    rec,
                    cnt = 0;
                for(i = 0, len = r.length; i < len; ++i){
                    rec = r[i];
                    if(this.indexOfId(rec.id) > -1){
                        this.doUpdate(rec);
                    }else{
                        toAdd.push(rec);
                        ++cnt;
                    }
                }
                this.totalLength = Math.max(t, this.data.length + cnt);
                this.add(toAdd);
            }
    Johnathan Hebert

  5. #5
    Sencha User
    Join Date
    Feb 2010
    Location
    Seattle, USA
    Posts
    19
    Vote Rating
    0
    gurpreet.saini is on a distinguished road

      0  

    Default


    I have a formpanel where I have:
    Code:
    buttons : [ {
                text : 'Search',
                handler : function() {
                    store.load( {
                        params : {
                            'start' : 0,
                            'limit' : 20
                        }
                    });
                }
            } ]
    my store is:

    Code:
        store = new Ext.data.JsonStore( {
            root : 'resList',
            totalProperty : 'totalCount',
            remoteSort : true,
            fields : [ 'cptNo', 'mptDesc', 'cptTitle', reason', 'mptCat', 'status' ],
            proxy : new Ext.data.HttpProxy( {
                url : RESULTS_URL,
                method : 'POST'
            })
        });
        
        store.setDefaultSort('cptNo', 'DESC');
    
        store.on('beforeload', function(mystore){
            mystore.baseParams = searchForm.getForm().getValues();
        });
    and my paging toolbar in the grid is :

    Code:
    bbar : new Ext.PagingToolbar( {
                pageSize : 20,
                store : store,
                displayInfo : true,
                displayMsg : 'Displaying topics {0} - {1} of {2}',
                emptyMsg : "No results to display"
            })

  6. #6
    Sencha User johnathanhebert's Avatar
    Join Date
    Apr 2008
    Posts
    77
    Vote Rating
    0
    johnathanhebert is on a distinguished road

      0  

    Default


    It looks right to me... are you sure you are seeing 0 and 20 in the request data on your server? And if so, are you sure the database query is using 0 and 20?
    Johnathan Hebert

  7. #7
    Sencha User
    Join Date
    Feb 2010
    Location
    Seattle, USA
    Posts
    19
    Vote Rating
    0
    gurpreet.saini is on a distinguished road

      0  

    Default


    First page works fine posting start: 0 and limit: 20 and the toolbar shows:
    Displaying topics 1 - 20 of 5660

    When I click next, values posted are start:20 and limit: 20
    I think start should be 21 and not 20.

    I got the reason .. my query was returning 21 records :P .. changes >= to >

    You directed me to the right path. Thanks ..

  8. #8
    Sencha User johnathanhebert's Avatar
    Join Date
    Apr 2008
    Posts
    77
    Vote Rating
    0
    johnathanhebert is on a distinguished road

      0  

    Default


    No problem, glad you got it worked out
    Johnathan Hebert

Similar Threads

  1. Selected records on list are incorrect
    By withanx in forum Sencha Touch 1.x: Discussion
    Replies: 8
    Last Post: 16 Feb 2011, 5:14 AM
  2. Total Row Count on PagingToolbar can be incorrect
    By banderson in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 29 Oct 2010, 12:29 PM
  3. [SOLVED]PagingToolBar 1st page Records Displayed incorrect
    By maquejp in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 14 Oct 2009, 4:39 AM
  4. Grid renderer showing incorrect values
    By catacaustic in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 28 Oct 2007, 5:33 PM

Thread Participants: 1

Tags for this Thread

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..."