Notes
- In v2.24.1, the
print_rows
option will allow using a custom css selector. - In v2.17.2, the print popup window now closes with the dialog window & jQuery version requirement was changed from v1.7+ to v1.2+.
-
In v2.17.0, added the
print_callback
option.
- This widget will only work in tablesorter version 2.8+ and jQuery version
1.7+1.2.6+ (v2.17.2; but filter & columnSelector widgets still require jQuery 1.7+). - The user can print all, visible or filtered rows. And, choose to print all or selected columns (using the columnSelector widget).
- By default, the widget is set to only print filtered rows & visible columns.
Options
Print widget default options (added inside of tablesorter widgetOptions
)
TIP! Click on the link in the option column to reveal full details (or toggle|show|hide all) or double click to update the browser location.
Option | Default | Description |
---|---|---|
print_title | '' |
This option sets the title of the popup window & ends up being printed at the top of each page.
If this option is blank, the print title is obtained from the table caption, then the table id, then just "table", in that order. |
print_dataAttrib | 'data-name' |
This option contains the data-attribute name which contains the modified table header content.
In this demo, the column selector widget is set up to also use the "data-name" attribute so the column selector popup and print header will display this alternate text. <th data-name="First">First Name</th> |
print_rows | 'filtered' |
Set this option to designate which rows are printed (v2.24.1).
This option has three settings (only the first letter is necessary):
|
print_columns | 'selected' |
Set this option to designate which columns are printed.
This option has three settings (only the first letter is necessary):
|
print_extraCSS | '' |
If you have any custom css to add to the print popup window, include it in this option
Use this option as follows: print_extraCSS : ".caption { display: none; }" |
print_styleSheet | '' |
If you have stylesheet you want to add to the print popup window, include the url in this option
Use this option as follows: print_styleSheet : "../css/theme.blue.css" |
print_callback | null |
This callback allows further processing of the table & style (v2.17.0)
When this callback is executed, three parameters are provided:
// print callback example print_callback : function( config, $table, printStyle ) { // do something to the table or printStyle string // use the following code to continue printing $.tablesorter.printTable.printOutput( config, $table.html(), printStyle ); } |
Method
- To make the print widget work programmatically, trigger a "printTable" event.
$('.print').click(function(){ $('.tablesorter').trigger('printTable'); });
Demo
First Name | Last Name | City | Age | Total | Discount | Date |
---|---|---|---|---|---|---|
Aaron | Johnson Sr | Atlanta | 35 | $5.95 | 22% | Jun 26, 2004 7:22 AM |
Aaron | Johnson | Yuma | 12 | $2.99 | 5% | Aug 21, 2009 12:21 PM |
Clark | Henry Jr | Tampa | 51 | $42.29 | 18% | Oct 13, 2000 1:15 PM |
Denni | Henry | New York | 28 | $9.99 | 20% | Jul 6, 2006 8:14 AM |
John | Hood | Boston | 33 | $19.99 | 25% | Dec 10, 2002 5:14 AM |
Clark | Kent Sr | Los Angeles | 18 | $15.89 | 44% | Jan 12, 2003 11:14 AM |
Peter | Kent Esq | Seattle | 45 | $153.19 | 44% | Jan 18, 2021 9:12 AM |
Peter | Johns | Milwaukee | 13 | $5.29 | 4% | Jan 8, 2012 5:11 PM |
Aaron | Evan | Chicago | 24 | $14.19 | 14% | Jan 14, 2004 11:23 AM |
Bruce | Evans | Upland | 22 | $13.19 | 11% | Jan 18, 2007 9:12 AM |
Clark | McMasters | Pheonix | 18 | $55.20 | 15% | Feb 12, 2010 7:23 PM |
Dennis | Masters | Indianapolis | 65 | $123.00 | 32% | Jan 20, 2001 1:12 PM |
John | Hood | Fort Worth | 25 | $22.09 | 17% | Jun 11, 2011 10:55 AM |