Added pager countChildRows option. See issue #396

This commit is contained in:
Mottie 2013-10-30 16:56:08 -05:00
parent 4990460d0b
commit c170dc6669
3 changed files with 36 additions and 3 deletions

View File

@ -65,6 +65,11 @@
// table row set to a height to compensate; default is false // table row set to a height to compensate; default is false
fixedHeight: false, fixedHeight: false,
// count child rows towards the set page size? (set true if it is a visible table row within the pager)
// if true, child row(s) may not appear to be attached to its parent row, may be split across pages or
// may distort the table if rowspan or cellspans are included.
countChildRows: false,
// remove rows from the table to speed up the sort of large tables. // remove rows from the table to speed up the sort of large tables.
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled. // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
removeRows: false, // removing rows in larger tables speeds up the sort removeRows: false, // removing rows in larger tables speeds up the sort
@ -199,7 +204,7 @@
if ( !rows[i].className.match(f) ) { if ( !rows[i].className.match(f) ) {
rows[i].style.display = ( j >= s && j < e ) ? '' : 'none'; rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
// don't count child rows // don't count child rows
j += rows[i].className.match(c.cssChildRow + '|' + c.selectorRemove.slice(1)) ? 0 : 1; j += rows[i].className.match(c.cssChildRow + '|' + c.selectorRemove.slice(1)) && !p.countChildRows ? 0 : 1;
} }
} }
} }

View File

@ -2781,6 +2781,28 @@ $.extend($.tablesorter.themes.jui, {
<td><a href="example-pager.html">Example</a></td> <td><a href="example-pager.html">Example</a></td>
</tr> </tr>
// count child rows towards the set page size? (set true if it is a visible table row within the pager)
// if true, child row(s) may not appear to be attached to its parent row, may be split across pages or
// may distort the table if rowspan or cellspans are included.
countChildRows: false,
<tr id="pager-countchildrows">
<td><a href="#" class="toggle2">countChildRows</a></td>
<td>Boolean</td>
<td>false</td>
<td>
If <code>true</code>, child rows will be counted towards the pager set size (<span class="version">v2.13</span>).
<div class="collapsible">
<br>
Caution: when <code>true</code>, child row(s) may not appear to be attached to its parent row, may be split across pages or
may distort the table if rowspan or cellspans are included within the child row.<br>
<br>
If this option is <code>false</code>, child row(s) will always appear on the same page as its parent.
</div>
</td>
<td></td>
</tr>
<tr id="pager-removerows"> <tr id="pager-removerows">
<td><a href="#" class="toggle2">removeRows</a></td> <td><a href="#" class="toggle2">removeRows</a></td>
<td>Boolean</td> <td>Boolean</td>

View File

@ -29,6 +29,11 @@ ts.addWidget({
// table row set to a height to compensate; default is false // table row set to a height to compensate; default is false
pager_fixedHeight: false, pager_fixedHeight: false,
// count child rows towards the set page size? (set true if it is a visible table row within the pager)
// if true, child row(s) may not appear to be attached to its parent row, may be split across pages or
// may distort the table if rowspan or cellspans are included.
pager_countChildRows: false,
// remove rows from the table to speed up the sort of large tables. // remove rows from the table to speed up the sort of large tables.
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled. // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
pager_removeRows: false, // removing rows in larger tables speeds up the sort pager_removeRows: false, // removing rows in larger tables speeds up the sort
@ -377,17 +382,18 @@ tsp = ts.pager = {
if (!c.widgetOptions.pager_ajaxUrl) { if (!c.widgetOptions.pager_ajaxUrl) {
var i, var i,
p = c.pager, p = c.pager,
wo = c.widgetOptions,
rows = c.$tbodies.eq(0).children(), rows = c.$tbodies.eq(0).children(),
l = rows.length, l = rows.length,
s = ( p.page * p.size ), s = ( p.page * p.size ),
e = s + p.size, e = s + p.size,
f = c.widgetOptions && c.widgetOptions.filter_filteredRow || 'filtered', f = wo && wo.filter_filteredRow || 'filtered',
j = 0; // size counter j = 0; // size counter
for ( i = 0; i < l; i++ ){ for ( i = 0; i < l; i++ ){
if ( !rows[i].className.match(f) ) { if ( !rows[i].className.match(f) ) {
rows[i].style.display = ( j >= s && j < e ) ? '' : 'none'; rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
// don't count child rows // don't count child rows
j += rows[i].className.match(c.cssChildRow + '|' + c.selectorRemove.slice(1)) ? 0 : 1; j += rows[i].className.match(c.cssChildRow + '|' + c.selectorRemove.slice(1)) && !wo.pager_countChildRows ? 0 : 1;
} }
} }
} }