mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Pager: custom pager controls update to work with filter widget. Fixes #605
This commit is contained in:
parent
bbc81ef0a6
commit
1a3f59c747
@ -16,6 +16,7 @@
|
||||
<!-- Tablesorter: required -->
|
||||
<link rel="stylesheet" href="../css/theme.blue.css">
|
||||
<script src="../js/jquery.tablesorter.js"></script>
|
||||
<script src="../js/jquery.tablesorter.widgets.js"></script>
|
||||
|
||||
<!-- Tablesorter: optional -->
|
||||
<link rel="stylesheet" href="../addons/pager/jquery.tablesorter.pager.css">
|
||||
@ -71,13 +72,13 @@
|
||||
$table
|
||||
.tablesorter({
|
||||
theme: 'blue',
|
||||
widgets: ['zebra', 'columns']
|
||||
widgets: ['zebra', 'columns', 'filter']
|
||||
})
|
||||
.tablesorterPager({
|
||||
// target the pager markup - see the HTML block below
|
||||
container: $pager,
|
||||
size: 10,
|
||||
output: 'showing: {startRow} to {endRow} ({totalRows})'
|
||||
output: 'showing: {startRow} to {endRow} ({filteredRows})'
|
||||
});
|
||||
|
||||
});
|
||||
@ -92,15 +93,14 @@
|
||||
</div>
|
||||
|
||||
<div id="main">
|
||||
<!--
|
||||
<p class="tip">
|
||||
<em>NOTE!</em> Lorem Ipsum
|
||||
<ul>
|
||||
<li>text.</li>
|
||||
<li>text.</li>
|
||||
</ul>
|
||||
</p>
|
||||
-->
|
||||
|
||||
<p class="tip">
|
||||
<em>NOTE!</em>
|
||||
<ul>
|
||||
<li>In <span class="version">v2.16.4</span>, code was updated to correctly count process pages.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h1>Demo</h1>
|
||||
<br>
|
||||
<!-- pager -->
|
||||
|
@ -38,16 +38,16 @@ $.tablesorter.customPagerControls = function(settings) {
|
||||
.on('pagerInitialized pagerComplete', function (e, c) {
|
||||
var indx, pages = $('<div/>'), pageArray = [],
|
||||
cur = c.page + 1,
|
||||
start = cur > 1 ? (c.totalPages - cur < options.aroundCurrent ? -(options.aroundCurrent + 1) + (c.totalPages - cur) : -options.aroundCurrent) : 0,
|
||||
start = cur > 1 ? (c.filteredPages - cur < options.aroundCurrent ? -(options.aroundCurrent + 1) + (c.filteredPages - cur) : -options.aroundCurrent) : 0,
|
||||
end = cur < options.aroundCurrent + 1 ? options.aroundCurrent + 3 - cur : options.aroundCurrent + 1;
|
||||
for (indx = start; indx < end; indx++) {
|
||||
if (cur + indx >= 1 && cur + indx < c.totalPages) { pageArray.push( cur + indx ); }
|
||||
if (cur + indx >= 1 && cur + indx < c.filteredPages) { pageArray.push( cur + indx ); }
|
||||
}
|
||||
if (pageArray.length) {
|
||||
// include first and last pages (ends) in the pagination
|
||||
for (indx = 0; indx < options.ends; indx++){
|
||||
if ($.inArray(indx + 1, pageArray) === -1) { pageArray.push(indx + 1); }
|
||||
if ($.inArray(c.totalPages - indx, pageArray) === -1) { pageArray.push(c.totalPages - indx); }
|
||||
if ($.inArray(c.filteredPages - indx, pageArray) === -1) { pageArray.push(c.filteredPages - indx); }
|
||||
}
|
||||
// sort the list
|
||||
pageArray = pageArray.sort(function(a, b){ return a - b; });
|
||||
|
Loading…
Reference in New Issue
Block a user