Pagination numbering error
Pagination numbering error
cathshadow
Posts: 20Questions: 0Answers: 0
On clicking next/previous, I tend to get Showing 1-15 of 60 results (correctly), on clicking 2, 3, 4 (or next/prev) I get 16-60 of 60 results (however its only showing 15 (correctly)) ... and then 31-60 and then 46 to 60...
the numbers being passed back by the program are ... "iTotalRecords":60,"iTotalDisplayRecords":60 ...
Any thoughts?
the numbers being passed back by the program are ... "iTotalRecords":60,"iTotalDisplayRecords":60 ...
Any thoughts?
This discussion has been closed.
Replies
Yes - the iTotalDisplayRecords return is wrong :-)
From the documentation of these two parameters ( http://datatables.net/usage/server-side ):
- iTotalRecords - Total records, before filtering (i.e. the total number of records in the database)
- iTotalDisplayRecords - Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned in this result set)
So if your result set only has 15 records in it after filtering, then iTotalDisplayRecords should be 15, not 60.
Allan
and the number is calculated as 15 for the pagination (ie. it only has one page).
even in the source code for their online ajax examples, they have iTotalDisplayRecords = 57 and iTotalRecords = 57...
the filtered seems to need to change only when you filter using the search filter box. then I change it to the (x) results..
(also, page one, which also receives iTotalDisplayRecords as 60 shows correctly 1-15 of 60 its pages 2-4 that have the issue)
the returned results from the online example:
{"sEcho":2,"iTotalRecords":"57","iTotalDisplayRecords":"57","aaData":[["Gecko","Mozilla 1.1","Win 95+ \/ OSX.1+","1.1","A"],["Gecko","Mozilla 1.2","Win 95+ \/ OSX.1+","1.2","A"],["Gecko","Mozilla 1.3","Win 95+ \/ OSX.1+","1.3","A"],["Gecko","Mozilla 1.4","Win 95+ \/ OSX.1+","1.4","A"],["Gecko","Mozilla 1.5","Win 95+ \/ OSX.1+","1.5","A"],["Gecko","Mozilla 1.6","Win 95+ \/ OSX.1+","1.6","A"],["Gecko","Mozilla 1.7","Win 98+ \/ OSX.1+","1.7","A"],["Gecko","Mozilla 1.8","Win 98+ \/ OSX.1+","1.8","A"],["Gecko","Seamonkey 1.1","Win 98+ \/ OSX.2+","1.8","A"],["Gecko","Epiphany 2.20","Gnome","1.8","A"]]}
Yes, but If I put it as 15 it doesn't allow me to go to the next page. ie. it says "1 to 15 (filtered from 60)"
and the number is calculated as 15 for the pagination (ie. it only has one page).
[/quote]
I don't really understand I'm afraid. The result suggests that your table has been filtered from 60 possible rows down to 15. If it is displaying 15 rows per page, the obviously it shouldn't allow you to see the next page since there are only 15 rows and it is already showing them.
> even in the source code for their online ajax examples, they have iTotalDisplayRecords = 57 and iTotalRecords = 57...
Yes - and then as soon as you apply a filter they diverge. As the documentation notes iTotalDisplayRecords and iTotalRecords must be the same when no filter is applied, and different when there is a filter.
iTotalRecords is the number of records regardless of filtering (in this case from what you say 60)
iTotalDisplayRecords is the number of records when filtering is taken into account (you say 15 here, so filtering must be applied).
So the question is, is 60 and 15 your expected result?
Allan
[quote]iTotalRecords is the number of records regardless of filtering (in this case from what you say 60)
iTotalDisplayRecords is the number of records when filtering is taken into account (you say 15 here, so filtering must be applied).[/quote]
The results arent actually being filtered. Its just when I click for page 2 i get 16-60 of 60 results (incorrect result count, but correct results)..
I get the correct entries, just the count at the bottom is wrong . its displaying 15 results (16-30), but saying it's showing 16-60
Allan
iTotalDisplayRecords is used using a "Select count(*) WHERE" (if there's a filter), else it returns the iTotalRecords value
-> from what I see in your example, iTotalRecords is the TOTAL number of records in the table (returned), and iTotalRecordsDisplay is the same (if you're showing all records (paginated), or different if you've filtered it. if you make iTotalRecords 16, not 60, how can it say next page if a total is less than a filtered total?). also, as in the example above, (datatables own example), both iTotalRecords, and iTotalRecordsDisplay are 57..
The point here is that 1 - 15(x) (or 2 - 60(x) <--- the problem) of 60 (y)(which is iTotalRecordsDisplay)
and 1 - x of (eg.12) filtered from 60 (z) which is iTotalRecords the filtered from form of the result
both are calculating the of (12 filtered from 60) or of (60) correctly.
the issue here is the automatic calculation of the pagination number is wrong. this is handled by datatables. the issue is at (X) not (Y) or (Z). those numbers are correct
Unless you add a filter to the table. If you were to type "Webkit" into the search box, then iTotalRecordsDisplay would be 8.
I'm afraid that I'm really lost with the x, y and x in your explanation.
The parameter "iTotalRecords" is simply the number of rows in the table regardless of filtering and paging. In my example that is the table cardinality. "iTotalRecordsDisplay" is simply the number of records that are available in the result set after filtering, regardless of paging (paging has absolutely nothing to do with these two numbers).
> the issue here is the automatic calculation of the pagination number is wrong. this is handled by data tables
What pagination number? The page is currently being shown?
Can you please link me to your page so I can see and understand the problem?
Allan
its the current page shown number . so it says the START int (16) to the END int (60) <--- this one is wrong of the TOTAL records from the FILTERED records.
ie. its showing the correct records for page 2 but telling me its showing 45 records on page 2 where its only showing 15. (it's only supposed to show 15)..
Page 1:
> Showing 1 to 10 of 32 entries (filtered from 58 total entries)
Page 2:
> Showing 11 to 20 of 32 entries (filtered from 58 total entries)
Allan
Page 1:
[quote]Showing 1 to 10 of 32 entries (filtered from 58 total entries)[/quote]
Page 2:
[quote]Showing 11 to 32 of 32 entries (filtered from 58 total entries)[/quote]
Allan
Allan
"aaData": [
[
"2256",
"user 1008"
],
[
"2257",
"user 1009"
],
[
"1349",
"user 101"
],
[
"2258",
"user 1010"
],
[
"2259",
"user 1011"
],
[
"2260",
"user 1012"
],
[
"2261",
"user 1013"
],
[
"2262",
"user 1014"
],
[
"2263",
"user 1015"
],
[
"2264",
"user 1016"
],
[
"2265",
"user 1017"
],
[
"2266",
"user 1018"
],
[
"2267",
"user 1019"
],
[
"1350",
"user 102"
],
[
"2268",
"user 1020"
]
],
"sEcho": "3",
"iTotalRecords": 60,
"iTotalDisplayRecords": 60
}
> Showing 11 to 32 of 32 entries (filtered from 58 total entries)
There are 15 records in the JSON reply and no filtering applied, so I would have expected it to look something like:
> Showing 16 to 30 of 60 entries
I'm afraid I think I would need to see the page in order to see what exactly is happening, since clearly something is amiss!
Allan
You are correct to assume this:
[quote]Showing 16 to 30 of 60 entries[/quote] should be showing, as this is what I'm expecting,
However
this
[quote]Showing 16 to 60 of 60 entries[/quote]
is what is actually displayed..
Also, to note, the problem doesn't happen every time the page is called or visited. sometimes the number is correct, sometimes not..
Allan
Incorrect:
http://www.freeimagehosting.net/rutqo
Another Anomaly:
http://www.freeimagehosting.net/3jeue
And a correct page:
http://www.freeimagehosting.net/mnj6z
Allan
Allan
I'm trying to think of what could go wrong and not give an JS error, and failing miserably. If you look at the BODY tag, does it have an iframe attached to it. If so, what is in the content of the body of the iframe?
Allan
illegal character
http://debug.datatables.net/bookmarklet/DT_Debug.js?rand=1329913526891
Line 195
... && l(e);}, k = !e.bJUI ? \"
Thanks for your help with this!
Allan
http://debug.datatables.net/bookmarklet/DT_Debug.js?rand=1329913526891
Line 195
Thanks,
Allan
I tried again and same error, then refreshed,and (posted this comment before but it seems to have.. disappeared..)
this time I got:
Upload complete - debug code: aledom
Thats the debug code I got..