Minor problem with paging and displayStart
Minor problem with paging and displayStart
I've stumbled across this issue using Datatable 1.10.5. See this jsfiddle
With 10 rows per page and a total of 29 rows, and setting displayStart to 5, it initially displays rows 6 to 15 as expected, with button [2] highlighted.
Clicking button [2] displays rows 11 to 20, which is slightly disconcerting, but makes sense.
Buttons [1] and [3] behave as expected.
Starting again, the [next] button shows rows 16 to 25, which is fine. But the [next] button is now greyed out. Nevertheless clicking on it gives rows 26 to 29. That's the problem: the [next] button being greyed out (and with no hover highlight) makes it look as though there are no more rows (although the info says 'Showing 16 to 25 of 29 entries').
Starting again at row 6, the [previous] button goes to rows 1 to 10, which seems correct.
This question has an accepted answers - jump to answer
Answers
Related to this is what happens when you want to start displaying the table at the last page.
I'm creating a table of 'recent transactions', and by default display the last page using:
and then the user can click on 'Previous' to look back in history.
The problem is that the last page is likely to be only part full.
I'd like the last page to be full, and the first to be possibly part-full, i.e. to have the 'framing' of the pagination fixed at the end of the data.
Is there an option for this? Or would it be possible to implement something like this?
Interesting. Thanks for the description. I haven't tested a non-modulo value of the page length for the start point. No reason why you shouldn't do that, but I think it is a fairly unusual use case.
That the next button is greyed out when there are still records left is most certainly a bug - I'll look into that and report back.
That is jumps to 11-20 on the second page might be a bug, I need to think about that. I think it probably isn't because it is going to page 2, which is indeed 11-20. The default pagination controls don't have floating point options, either you are on page 1 or 2 or 3, etc, but not 2.5 or the like. That you can force it to do that on start up might be where the actual bug is here...
DataTables actually used to work like that (try it with 1.9 and you will get the result you want - although not with all the new API and camelCase goodness of 1.10...), but after years of trying to decide if it was a bug or not I finally changed it to make the pages discrete - which is probably the foundation of all the issues that you highlight here...
A custom paging plug-in could probably do what you are looking for - I'll need to check that as well.
Allan
Thanks for your reply Allan.
I understand that 'whole pages starting at the beginning' is probably what most people want.
But my first two uses of DataTables don't quite fit that neat approach.
One, as I mentioned, is historical data, where the user's view starts at the last page and then they can look back at older records.
The other is a list of club meetings, ordered by date, starting in the past and ending in the future. The default view should start with the 'next' meeting, which depends on the current date.
Neither page is for public consumption, so I'm afraid I can't provide a link, but I'm sure you get the idea.
Chris