mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Print: rows option now accepts custom css selectors
This commit is contained in:
parent
52ec39464a
commit
b2ae0d194d
16
dist/js/widgets/widget-print.min.js
vendored
16
dist/js/widgets/widget-print.min.js
vendored
@ -15,11 +15,13 @@ g.find("["+e.print_dataAttrib+"]").each(function(){f=a(this),f.text(f.attr(e.pri
|
||||
// === rows ===
|
||||
// Assume 'visible' means rows hidden by the pager (rows set to 'display:none')
|
||||
// or hidden by a class name which is added to the wo.print_extraCSS definition
|
||||
/a/i.test(e.print_rows)?
|
||||
// force show of all rows
|
||||
h+="tbody tr { display: table-row !important; }":/f/i.test(e.print_rows)&&(
|
||||
// add definition to show all non-filtered rows (cells hidden by the pager)
|
||||
h+="tbody tr:not(."+(e.filter_filteredRow||"filtered")+") { display: table-row !important; }"),
|
||||
// look for jQuery filter selector in wo.print_rows & use if found
|
||||
/^f/i.test(e.print_rows)?h+="tbody tr:not(."+(e.filter_filteredRow||"filtered")+") { display: table-row !important; }":/^a/i.test(e.print_rows)?
|
||||
// default force show of all rows
|
||||
h+="tbody tr { display: table-row !important; }":/^[.#:\[]/.test(e.print_rows)&&(
|
||||
// look for '.' (class selector), '#' (id selector),
|
||||
// ':' (basic filters, e.g. ':not()') or '[' (attribute selector start)
|
||||
h+="tbody tr"+e.print_rows+" { display: table-row !important; }"),
|
||||
// === columns ===
|
||||
// columnSelector -> c.selector.$style
|
||||
// Assume 'visible' means hidden columns have a 'display:none' style, or a class name
|
||||
@ -34,8 +36,8 @@ printOutput:function(a,b,d){var e=a.widgetOptions,f=window.open("",e.print_title
|
||||
// Print preview in Chrome doesn't work without this code
|
||||
return f.document.write("<html><head><title>"+g+"</title>"+(e.print_styleSheet?'<link rel="stylesheet" href="'+e.print_styleSheet+'">':"")+"<style>"+d+"</style></head><body>"+b+"</body></html>"),f.document.close(),setTimeout(function(){f.print(),f.close()},10),!0},remove:function(a){a.$table.off(c.event)}};b.addWidget({id:"print",options:{print_title:"",// this option > caption > table id > 'table'
|
||||
print_dataAttrib:"data-name",// header attrib containing modified header name
|
||||
print_rows:"filtered",// (a)ll, (v)isible or (f)iltered
|
||||
print_columns:"selected",// (a)ll or (s)elected (if columnSelector widget is added)
|
||||
print_rows:"filtered",// (a)ll, (v)isible, (f)iltered or custom css selector
|
||||
print_columns:"selected",// (a)ll, (v)isbible or (s)elected (if columnSelector widget is added)
|
||||
print_extraCSS:"",// add any extra css definitions for the popup window here
|
||||
print_styleSheet:"",// add the url of your print stylesheet
|
||||
// callback executed when processing completes
|
||||
|
@ -80,7 +80,7 @@
|
||||
|
||||
print_title : '', // this option > caption > table id > "table"
|
||||
print_dataAttrib : 'data-name', // header attrib containing modified header name
|
||||
print_rows : 'f', // (a)ll, (v)isible or (f)iltered
|
||||
print_rows : 'f', // (a)ll, (v)isible, (f)iltered, or custom css selector
|
||||
print_columns : 's', // (a)ll, (v)isible or (s)elected (columnSelector widget)
|
||||
print_extraCSS : '', // add any extra css definitions for the popup window here
|
||||
print_styleSheet : '../css/theme.blue.css', // add the url of your print stylesheet
|
||||
@ -118,6 +118,7 @@
|
||||
<h3><a href="#">Notes</a></h3>
|
||||
<div>
|
||||
<ul>
|
||||
<li>In <span class="version updated">v2.24.1</span>, the <code>print_rows</code> option will allow using a custom css selector.</li>
|
||||
<li>In <span class="version">v2.17.2</span>, the print popup window now closes with the dialog window & jQuery version requirement was changed from v1.7+ to v1.2+.</li>
|
||||
<li>
|
||||
In <span class="version">v2.17.0</span>, added the <code>print_callback</code> option.<br>
|
||||
@ -169,7 +170,7 @@
|
||||
<td><a href="#" class="permalink">print_rows</a></td>
|
||||
<td><code>'filtered'</code></td>
|
||||
<td>
|
||||
Set this option to designate which rows are printed.
|
||||
Set this option to designate which rows are printed (<span class="version updated">v2.24.1</span>).
|
||||
<div class="collapsible">
|
||||
<br>
|
||||
This option has three settings (only the first letter is necessary):
|
||||
@ -177,6 +178,20 @@
|
||||
<li><code>'all'</code> or <code>'a'</code> - always print all rows (this will not work if the pager has `removeRows` set to `true`).</li>
|
||||
<li><code>'filtered'</code> or <code>'f'</code> - only filtered rows are printed (even if the pager is applied).</li>
|
||||
<li><code>'visible'</code> or <code>'v'</code> - only visible rows are printed (the current pager page).</li>
|
||||
<li>css selector - include a css selector to apply to a row (<span class="version">v2.24.1</span>).
|
||||
<ul>
|
||||
<li>For example, <code>'.checked'</code>, <code>'[data-region~="west"]</code>, <code>':nth-child(2n)'</code></li>
|
||||
<li>For reference, internally, this option is added immediately after (no space) a <code>'tr'</code> css selector.</li>
|
||||
<li>For this option to be used as a css selector, a check of the following characters at the start of the string is done:
|
||||
<ul>
|
||||
<li><code>'.'</code> (class selector)</li>
|
||||
<li><code>'#'</code> (id selector)</li>
|
||||
<li><code>':'</code> (pseudo selector)</li>
|
||||
<li><code>'['</code> (start of an attribute selector)</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<span class="label label-info">Note</span> only rows contained within the table are printed; i.e. if ajax is being used to populate the table, only the currently loaded rows will print.
|
||||
</div>
|
||||
|
@ -44,12 +44,16 @@
|
||||
// === rows ===
|
||||
// Assume 'visible' means rows hidden by the pager (rows set to 'display:none')
|
||||
// or hidden by a class name which is added to the wo.print_extraCSS definition
|
||||
if (/a/i.test(wo.print_rows)) {
|
||||
// force show of all rows
|
||||
printStyle += 'tbody tr { display: table-row !important; }';
|
||||
} else if (/f/i.test(wo.print_rows)) {
|
||||
// add definition to show all non-filtered rows (cells hidden by the pager)
|
||||
// look for jQuery filter selector in wo.print_rows & use if found
|
||||
if ( /^f/i.test( wo.print_rows ) ) {
|
||||
printStyle += 'tbody tr:not(.' + ( wo.filter_filteredRow || 'filtered' ) + ') { display: table-row !important; }';
|
||||
} else if ( /^a/i.test( wo.print_rows ) ) {
|
||||
// default force show of all rows
|
||||
printStyle += 'tbody tr { display: table-row !important; }';
|
||||
} else if ( /^[.#:\[]/.test( wo.print_rows ) ) {
|
||||
// look for '.' (class selector), '#' (id selector),
|
||||
// ':' (basic filters, e.g. ':not()') or '[' (attribute selector start)
|
||||
printStyle += 'tbody tr' + wo.print_rows + ' { display: table-row !important; }';
|
||||
}
|
||||
|
||||
// === columns ===
|
||||
@ -106,8 +110,8 @@
|
||||
options: {
|
||||
print_title : '', // this option > caption > table id > 'table'
|
||||
print_dataAttrib : 'data-name', // header attrib containing modified header name
|
||||
print_rows : 'filtered', // (a)ll, (v)isible or (f)iltered
|
||||
print_columns : 'selected', // (a)ll or (s)elected (if columnSelector widget is added)
|
||||
print_rows : 'filtered', // (a)ll, (v)isible, (f)iltered or custom css selector
|
||||
print_columns : 'selected', // (a)ll, (v)isbible or (s)elected (if columnSelector widget is added)
|
||||
print_extraCSS : '', // add any extra css definitions for the popup window here
|
||||
print_styleSheet : '', // add the url of your print stylesheet
|
||||
// callback executed when processing completes
|
||||
|
Loading…
Reference in New Issue
Block a user