NOTE!
- This widget can be applied to the original plugin. The code is in the "jquery.tablesorter.widgets.js" file.
- Added filter header option and class name to allow disabling the filter in a specific column in v2.0.19.1.
- The Discount column has the "filter-false" class added to the header - see the HTML on how to add this ability.
- The Date column has the "headers" option applied to disable the sort and the filter - see the table options in the javascript for this example.
- Replaced
widgetFilterChildRows
option withwidgetOptions.filter_childRows
. New! v2.1 - Added
widgetOptions.filter_startsWith
option, which whentrue
, allows you to search the table from the starting of the table cell text. Use the toggle button to see the difference, and that it can be dynamically changed! New! v2.1 - Added
widgetOptions.filter_cssFilter
option, which allows you to defined the css class applied to the filter row and each search input. New! v2.1 - Additional filter widget specific options are included in the javascript below, with an explanation.
- Please note that using the pager plugin with this filter widget will have unexpected results - I haven't figured out how to fix the problem.
- This widget uses jQuery's
.nextUntil()
function which is only available is jQuery version 1.4+.
Demo
filter_startsWith : false (if true, search from beginning of cell content only)First Name | Last Name | Age | Total | Discount | Date |
---|---|---|---|---|---|
Philip | Johnson | 25 | $5.95 | 22% | Jun 26, 2004 7:22 AM |
Aaron | Hibert | 12 | $2.99 | 5% | Aug 21, 2009 12:21 PM |
Brandon | Henry | 51 | $42.29 | 18% | Oct 13, 2000 1:15 PM |
Peter | Parker | 28 | $9.99 | 20% | Jul 6, 2006 8:14 AM |
John | Hood | 33 | $19.99 | 25% | Dec 10, 2002 5:14 AM |
Clark | Kent | 18 | $15.89 | 44% | Jan 12, 2003 11:14 AM |
Bruce | Almighty | 45 | $153.19 | 44% | Jan 18, 2001 9:12 AM |
Bruce | Evans | 22 | $13.19 | 11% | Jan 18, 2007 9:12 AM |
Page Header
<!-- blue theme stylesheet --> <link rel="stylesheet" href="../css/blue/style.css"> <!-- tablesorter plugin --> <script src="../js/jquery.tablesorter.js"></script> <!-- tablesorter widget file - loaded after the plugin --> <script src="../js/jquery.tablesorter.widgets.js"></script>
Javascript
CSS
/* filter widget, added to style.css themes */ table.tablesorter thead tr.filters input { width: 95%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } table.tablesorter thead tr.filters, table.tablesorter thead tr.filters td { text-align: center; background: #fff; } /* optional disabled input styling */ table.tablesorter thead tr.filters input.disabled { opacity: 0.5; filter: alpha(opacity=50); }