-
28 Feb 2011 12:19 PM #1
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
-GLast edited by gurpreet.saini; 28 Feb 2011 at 12:26 PM. Reason: image
-
28 Feb 2011 12:22 PM #2
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
-
28 Feb 2011 12:28 PM #3
Yes it is.
{
"totalCount": 5660,
"tasksList": [.......]
}
-
28 Feb 2011 12:57 PM #4
A quick look at PagingToolbar in the ExtJS source shows:
in the Ext.PagingToolbar.updateInfo() (private) method... and the store.getTotalCount() method is returning the totalLength property of the store:Code:var msg = count == 0 ? this.emptyMsg : String.format( this.displayMsg, this.cursor+1, this.cursor+count, this.store.getTotalCount() );
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:getTotalCount : function(){ return this.totalLength || 0; },
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
-
28 Feb 2011 1:21 PM #5
I have a formpanel where I have:
my store is:Code:buttons : [ { text : 'Search', handler : function() { store.load( { params : { 'start' : 0, 'limit' : 20 } }); } } ]
and my paging toolbar in the grid 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(); });
Code:bbar : new Ext.PagingToolbar( { pageSize : 20, store : store, displayInfo : true, displayMsg : 'Displaying topics {0} - {1} of {2}', emptyMsg : "No results to display" })
-
28 Feb 2011 1:31 PM #6
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
-
28 Feb 2011 1:40 PM #7
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 ..
-
28 Feb 2011 6:12 PM #8
No problem, glad you got it worked out
Johnathan Hebert
Similar Threads
-
Selected records on list are incorrect
By withanx in forum Sencha Touch 1.x: DiscussionReplies: 8Last Post: 16 Feb 2011, 5:14 AM -
Total Row Count on PagingToolbar can be incorrect
By banderson in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 29 Oct 2010, 12:29 PM -
[SOLVED]PagingToolBar 1st page Records Displayed incorrect
By maquejp in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 14 Oct 2009, 4:39 AM -
Grid renderer showing incorrect values
By catacaustic in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 28 Oct 2007, 5:33 PM


Reply With Quote