Limit number of page tabs with Bootstrap Pagination
Limit number of page tabs with Bootstrap Pagination
![cfdude](https://secure.gravatar.com/avatar/1571dd1fb11e9a38bc7edab5c368db99/?default=https%3A%2F%2Fvanillicon.com%2F1571dd1fb11e9a38bc7edab5c368db99_200.png&rating=g&size=120)
I've been using DataTables with Editor / TableTools in a current project and it's also using BootStrap styling. One thing I noticed was that I could not control the number of page tabs being displayed when using the BootStrap style.
The only fix I found was to modify the BootStrap Pagination plugin, found here https://datatables.net/plug-ins/pagination , in the fnUpdate function I added one more 'if' before the for loop:
[code]
if (jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPage < iEnd){
iEnd = jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPage;
}
[/code]
Doing this allowed me to set the number of page tabs I wanted similar to the full text number method. This is what i use on the calling page that initializes the DataTable.
[code]
jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPage=3;
[/code]
I hope this helps someone else.
The only fix I found was to modify the BootStrap Pagination plugin, found here https://datatables.net/plug-ins/pagination , in the fnUpdate function I added one more 'if' before the for loop:
[code]
if (jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPage < iEnd){
iEnd = jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPage;
}
[/code]
Doing this allowed me to set the number of page tabs I wanted similar to the full text number method. This is what i use on the calling page that initializes the DataTable.
[code]
jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPage=3;
[/code]
I hope this helps someone else.
This discussion has been closed.
Replies
[code]
var iListLength = ( jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPage < 5 ? jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPage : 5 );
[/code]
The good news is that in DataTables 1.10 I've added an abstraction layer to the pagination controls, so the logic for calculating what buttons are shown, and how those buttons are actually displayed is separated into two parts. The upshot is that the Bootstrap integration just needs to provide a renderer for the buttons and the logic for what buttons are shown is retained internally. The `$.fn.dataTable.ext.pager.numbers_length` property is used to control the button of paging buttons shown in 1.10 (default 7).
Allan