Pagination: How to control number of pages either side of active
Pagination: How to control number of pages either side of active
![ButchNZ](https://datatables.net/forums/uploads/userpics/162/nB8LB8E1C5W48.png)
How can I change the pagination number either side of active?
By default I have:
Ideally I'd like that to be:
<< < 1 2 3 4 5 6 7 > >>
Where the current page is 4.
Said in words, 3 either side of current when you can.
Never show first/last page as a page link unless it's part of the 7 page sequence (there's << >> buttons for that).
I saw I can use:
$.fn.DataTable.ext.pager.numbers_length = 6;
To change number of pages but didn't quite do the above.
I read this page in the examples but doesn't seem possible there.
https://datatables.net/examples/basic_init/alt_pagination.html
This question has an accepted answers - jump to answer
Answers
I think the
paging.boundaryNumbers
option is what you are looking for here. It will still show the ellipsis to indicate a gap, but you could use CSS to hide those elements if you so wished to do so.Allan
I've added it like this with no change.
Did I do it wrong or maybe DOM templates changed?
My DOM template is:
You can't use
dom
andlayout
at the same time.boundaryNumber
can only be done through thelayout
option. Also, theboundaryNumber
feature requires DataTables 2.0.4 or newer.I'm working on updates for DataTables 2.1 at the moment that will give the same flexibility as
dom
currently does for setting class names and the like. At the moment, what you have cannot be exactly reproduced withlayout
, but 2.1 will make that possible.Allan
Cool no problem. Thanks!