Pager: Add pageReset option. Fixes #565

This commit is contained in:
Mottie 2014-04-20 01:59:23 -05:00
parent b258cd8c92
commit f65e3dc9b3
3 changed files with 22 additions and 2 deletions

View File

@ -58,6 +58,10 @@
// starting page of the pager (zero based index)
page: 0,
// reset pager after filtering; set to desired page #
// set to false to not change page at filter start
pageReset: 0,
// Number of visible rows
size: 10,
@ -674,7 +678,9 @@
.unbind('filterStart filterEnd sortEnd disable enable destroy update updateRows updateAll addRows pageSize '.split(' ').join('.pager '))
.bind('filterStart.pager', function(e, filters) {
p.currentFilters = filters;
p.page = 0; // fixes #456
if (p.pageReset !== false) {
p.page = p.pageReset; // fixes #456 & #565
}
})
// update pager after filter widget completes
.bind('filterEnd.pager sortEnd.pager', function() {

View File

@ -3176,6 +3176,14 @@ This ajaxProcessing function must return an object with "total", "headers" and "
<td><a href="example-pager.html">Example</a></td>
</tr>
<tr id="pager-page-reset">
<td><span class="permalink">pageReset</span></td>
<td>Boolean Numeric</td>
<td>0</td>
<td>Reset pager to this page after filtering; set to desired page number (zero-based index), or <code>false</code> to not change page at filter start.</td>
<td></td>
</tr>
<tr id="pager-size">
<td><span class="permalink">size</span></td>
<td>Numeric</td>

View File

@ -19,6 +19,10 @@ ts.addWidget({
// starting page of the pager (zero based index)
pager_startPage: 0,
// reset pager after filtering; set to desired page #
// set to false to not change page at filter start
pager_pageReset: 0,
// Number of visible rows
pager_size: 10,
@ -210,7 +214,9 @@ tsp = ts.pager = {
.unbind('filterStart filterEnd sortEnd disable enable destroy update updateRows updateAll addRows pageSize '.split(' ').join('.pager '))
.bind('filterStart.pager', function(e, filters) {
p.currentFilters = filters;
p.page = 0; // fixes #456
if (wo.pager_pageReset !== false) {
p.page = wo.pager_pageReset; // fixes #456 & #565
}
})
// update pager after filter widget completes
.bind('filterEnd.pager sortEnd.pager', function() {