Simple Incremental navigation (Bootstrap)
Shows forward/back buttons and all known page numbers.
- Author: Jovan Popovic
This pagination style shows Previous/Next buttons, and page numbers only for "known" pages that are visited at least once time using [Next>] button. Initially only Prev/Next buttons are shown (Prev is initially disabled).
[<Previous] [Next>]
When user navigates through the pages using [Next>] button, navigation shows the numbers for the previous pages. As an example, when user reaches page 2, page numbers 1 and 2 are shown:
[<Previous] 1 2 [Next>]
When user reaches page 4, page numbers 1, 2, 3, and 4 are shown:
[<Previous] 1 2 3 4 [Next>]
When user navigates back, pagination will remember the last page number he reached and the numbesr up to the last known page are shown. As an example, when user returns to the page 2, page numbers 1, 2, 3, and 4 are still shown:
[<Previous] 1 2 3 4 [Next>]
This pagination style is designed for users who will not directly jump to the random page that they have not opened before. Assumption is that users will discover new pages using [Next>] button. This pagination enables users to easily go back and forth to any page that they discovered.
Key benefit: This pagination supports usual pagination pattern and does not require server to return total count of items just to calculate last page and all numbers. This migh be huge performance benefit because server does not need to execute two queries in server-side processing mode: - One to get the records that will be shown on the current page, - Second to get the total count just to calculate full pagination.
Without second query, page load time might be 2x faster, especially in cases when server can quickly get top 100 records, but it would need to scan entire database table just to calculate the total count and position of the last page. This pagination style is reasonable trade-off between simple and fullnumbers pagination.
Use
This plug-in can be obtained and used in multiple different ways.
Browser
This plug-in is available on the DataTables CDN:
The plug-in will then automatically register itself against a global DataTables instance. This file can also be used if you are using an AMD loader such as Require.js.
Note that if you are using multiple plug-ins, it can be beneficial in terms of performance to combine the plug-ins into a single file and host it on your own server, rather than making multiple requests to the DataTables CDN.
NPM
The plug-ins are all available on NPM (which can also be used with Yarn or any other Javascript package manager) as part of the datatables.net-plugins
package. To use this plug-in, first install the plug-ins package:
npm install datatables.net-plugins
ES modules
Then, if you are using ES modules, import datatables.net
, any other DataTables extensions you need, and the plug-in:
import DataTable from 'datatables.net';
import 'datatables.net-plugins/pagination/simple_incremental_bootstrap.mjs';
CommonJS
If you are using a CommonJS loader for Node (e.g. with older versions of Webpack, or non-module Node code) use the following method to require
the plug-in:
var $ = require('jquery');
var DataTable = require('datatables.net');
require('datatables.net-plugins/pagination/simple_incremental_bootstrap.js');
Example
$(document).ready(function() {
$('#example').dataTable( {
"pagingType": "simple_incremental_bootstrap"
} );
} );
Version control
If you have any ideas for how this plug-in can be improved, or spot anything that is in error, it is available on GitHub and pull requests are very welcome!
- This plug-in: simple_incremental_bootstrap.js
- Full DataTables plug-ins repository: DataTables/Plugins