Filter: check match on both internal & external filters. See #1177

This commit is contained in:
Rob Garrison 2016-03-23 19:33:25 -05:00
parent 8ed9156cbb
commit 16c625f5a8
3 changed files with 13 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@
<!-- Tablesorter: required -->
<link rel="stylesheet" href="../css/theme.blue.css">
<script src="../js/jquery.tablesorter.js"></script>
<script src="../js/jquery.tablesorter.widgets.js"></script>
<script src="../js/widgets/widget-filter.js"></script>
<script id="js">$(function() {
@ -93,7 +93,7 @@
<li>As of <span class="version">v2.15</span>,
<ul>
<li>A new filter widget <a href="index.html#widget-filter-external"><code>filter_external</code> option</a> has been added that essentially does the same thing as the <a href="index.html#function-bindsearch"><code>$.tablesorter.bindSearch</code></a> function.</li>
<li>Use either to bind external search inputs.</li>
<li>Use either to bind external search inputs.</li>
<li>To change an input from searching one column (or all columns) to search any other column, call the <code>$.tablesorter.bindSearch</code> function to update the external inputs, even if the inputs are set using the <code>filter_external</code> option. Pass an additional <code>false</code> flag as the last parameter to force the inputs to update.
<pre class="prettyprint lang-js">$.tablesorter.bindSearch( $('table'), $('.search'), false );</pre>
</li>

View File

@ -1034,6 +1034,7 @@
},
matchType: function( c, columnIndex ) {
var isMatch,
wo = c.widgetOptions,
$el = c.$headerIndexed[ columnIndex ];
// filter-exact > filter-match > filter_matchType for type
if ( $el.hasClass( 'filter-exact' ) ) {
@ -1042,7 +1043,14 @@
isMatch = true;
} else {
// filter-select is not applied when filter_functions are used, so look for a select
$el = c.$filters.eq( columnIndex ).find( '.' + tscss.filter );
if ( wo.filter_columnFilters ) {
$el = c.$filters
.find( '.' + tscss.filter )
.add( wo.filter_$externalFilters )
.filter( '[data-column="' + columnIndex + '"]' );
} else if ( wo.filter_$externalFilters ) {
$el = wo.filter_$externalFilters.filter( '[data-column="' + columnIndex + '"]' );
}
isMatch = $el.length ?
c.widgetOptions.filter_matchType[ ( $el[ 0 ].nodeName || '' ).toLowerCase() ] === 'match' :
// default to exact, if no inputs found
@ -1133,7 +1141,7 @@
// in case select filter option has a different value vs text 'a - z|A through Z'
ffxn = wo.filter_columnFilters ?
c.$filters.add( c.$externalFilters )
c.$filters.add( wo.filter_$externalFilters )
.filter( '[data-column="' + columnIndex + '"]' )
.find( 'select option:selected' )
.attr( 'data-function-name' ) || '' : '';