diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 4550e608..afc5d273 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -173,7 +173,7 @@ updatePageDisplay = function(table, p, completed) { if ( p.initializing ) { return; } - var s, t, $out, $el, indx, len, options, + var s, t, $out, $el, indx, len, options, output, c = table.config, namespace = c.namespace + 'pager', sz = parsePageSize( p, p.size, 'get' ); // don't allow dividing by zero @@ -196,8 +196,12 @@ if (typeof p.output === 'function') { s = p.output(table, p); } else { + output = $out + // get output template from data-pager-output or data-pager-output-filtered + .attr('data-pager-output' + (p.filteredRows < p.totalRows ? '-filtered' : '')) || + p.output; // form the output string (can now get a new output string from the server) - s = ( p.ajaxData && p.ajaxData.output ? p.ajaxData.output || p.output : p.output ) + s = ( p.ajaxData && p.ajaxData.output ? p.ajaxData.output || output : output ) // {page} = one-based index; {page+#} = zero based index +/- value .replace(/\{page([\-+]\d+)?\}/gi, function(m, n){ return p.totalPages ? p.page + (n ? parseInt(n, 10) : 1) : 0; @@ -496,7 +500,7 @@ $h.find('.' + ts.css.headerIn).html( th[j] ); if (hsh && $sh.length) { // add sticky header to container just in case it contains pager controls - p.$container = p.$container.add( wo.$sticky ); + p.$container = p.$container.add( c.widgetOptions.$sticky ); $sh.eq(j).find('.' + ts.css.headerIn).html( th[j] ); } } diff --git a/docs/example-pager.html b/docs/example-pager.html index d4e845e8..1199834f 100644 --- a/docs/example-pager.html +++ b/docs/example-pager.html @@ -58,7 +58,7 @@ // also {page:input} & {startRow:input} will add a modifiable input in place of the value // In v2.27.7, this can be set as a function // output: function(table, pager) { return 'page ' + pager.startRow + ' - ' + pager.endRow; } - output: '{startRow:input} to {endRow} ({totalRows})', + output: '{startRow:input} – {endRow} / {totalRows} rows', // apply disabled classname (cssDisabled option) to the pager arrows when the rows // are at either extreme is visible; default is true @@ -116,7 +116,7 @@ .tablesorter({ theme: 'blue', widthFixed: true, - widgets: ['zebra'] + widgets: ['zebra', 'filter'] }) // bind to pager events @@ -239,6 +239,7 @@ NOTE! The following are not part of the original plugin:
data-pager-output
and data-pager-output-filtered
attributes which override the output
option when set on the pageDisplay
element.data-pager-output
and data-pager-output-filtered
attributes which override the output
option when set on the pageDisplay
element.applyWidgetId
to re-apply the pager widget after being destroyed.