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 -->
|
<!-- Tablesorter: required -->
|
||||||
<link rel="stylesheet" href="../css/theme.blue.css">
|
<link rel="stylesheet" href="../css/theme.blue.css">
|
||||||
<script src="../js/jquery.tablesorter.js"></script>
|
<script src="../js/jquery.tablesorter.js"></script>
|
||||||
|
<script src="../js/jquery.tablesorter.widgets.js"></script>
|
||||||
|
|
||||||
<!-- Tablesorter: optional -->
|
<!-- Tablesorter: optional -->
|
||||||
<link rel="stylesheet" href="../addons/pager/jquery.tablesorter.pager.css">
|
<link rel="stylesheet" href="../addons/pager/jquery.tablesorter.pager.css">
|
||||||
@ -71,13 +72,13 @@
|
|||||||
$table
|
$table
|
||||||
.tablesorter({
|
.tablesorter({
|
||||||
theme: 'blue',
|
theme: 'blue',
|
||||||
widgets: ['zebra', 'columns']
|
widgets: ['zebra', 'columns', 'filter']
|
||||||
})
|
})
|
||||||
.tablesorterPager({
|
.tablesorterPager({
|
||||||
// target the pager markup - see the HTML block below
|
// target the pager markup - see the HTML block below
|
||||||
container: $pager,
|
container: $pager,
|
||||||
size: 10,
|
size: 10,
|
||||||
output: 'showing: {startRow} to {endRow} ({totalRows})'
|
output: 'showing: {startRow} to {endRow} ({filteredRows})'
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -92,15 +93,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<!--
|
|
||||||
<p class="tip">
|
<p class="tip">
|
||||||
<em>NOTE!</em> Lorem Ipsum
|
<em>NOTE!</em>
|
||||||
<ul>
|
<ul>
|
||||||
<li>text.</li>
|
<li>In <span class="version">v2.16.4</span>, code was updated to correctly count process pages.</li>
|
||||||
<li>text.</li>
|
</ul>
|
||||||
</ul>
|
</p>
|
||||||
</p>
|
|
||||||
-->
|
|
||||||
<h1>Demo</h1>
|
<h1>Demo</h1>
|
||||||
<br>
|
<br>
|
||||||
<!-- pager -->
|
<!-- pager -->
|
||||||
|
@ -38,16 +38,16 @@ $.tablesorter.customPagerControls = function(settings) {
|
|||||||
.on('pagerInitialized pagerComplete', function (e, c) {
|
.on('pagerInitialized pagerComplete', function (e, c) {
|
||||||
var indx, pages = $('<div/>'), pageArray = [],
|
var indx, pages = $('<div/>'), pageArray = [],
|
||||||
cur = c.page + 1,
|
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;
|
end = cur < options.aroundCurrent + 1 ? options.aroundCurrent + 3 - cur : options.aroundCurrent + 1;
|
||||||
for (indx = start; indx < end; indx++) {
|
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) {
|
if (pageArray.length) {
|
||||||
// include first and last pages (ends) in the pagination
|
// include first and last pages (ends) in the pagination
|
||||||
for (indx = 0; indx < options.ends; indx++){
|
for (indx = 0; indx < options.ends; indx++){
|
||||||
if ($.inArray(indx + 1, pageArray) === -1) { pageArray.push(indx + 1); }
|
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
|
// sort the list
|
||||||
pageArray = pageArray.sort(function(a, b){ return a - b; });
|
pageArray = pageArray.sort(function(a, b){ return a - b; });
|
||||||
|
Loading…
Reference in New Issue
Block a user