mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Filter: Remove not any match limitation
This commit is contained in:
parent
89be0907cb
commit
b473f4f653
4
dist/js/widgets/widget-filter.min.js
vendored
4
dist/js/widgets/widget-filter.min.js
vendored
File diff suppressed because one or more lines are too long
@ -73,6 +73,7 @@
|
||||
<h3><a href="#">Notes</a></h3>
|
||||
<div>
|
||||
<ul>
|
||||
<li>In <span class="version updated">v2.26.2</span>, The not match (<code>!</code>) limitation is no longer in place. Try searching in the "Match any column" for <button type="button" data-column="all">!aaron</button>.
|
||||
<li>In <span class="version">v2.22.0</span>, AnyMatch searches for specific columns will no longer save filter data to each targeted column. See the "AnyMatch Searches" section below.</li>
|
||||
<li>In <span class="version">v2.20.0</span>, <a href="https://github.com/MaksimProgr">@MasksimProgr</a> added a method to allow targeting a specific column using the anyMatch filter. Find more details in the AnyMatch section below.</li>
|
||||
<li>In <span class="version">v2.18.0</span>, the external search data column can be set to multiple columns (<code>data-column="0-2,4,6-7"</code>). Please see the <a href="example-widget-filter-external-inputs.html">Filter Widget External Inputs</a> demo for more details.</li>
|
||||
@ -127,13 +128,17 @@
|
||||
"Fred" < 10 // false</pre>* For comparisons, letters have a greater <a href="http://en.wikipedia.org/wiki/Ascii#ASCII_printable_characters">ASCII value</a> than numbers.
|
||||
</li>
|
||||
<li>Range query - A search for any number range (<code>1 - 10</code>) is not allowed because, if any columns contain text, then no rows will result. The examples are the same as the search operators examples above.</li>
|
||||
<li>Not Match query - A search for not matches (<code>!a</code>) is not allowed because tables that contain both numbers and text (in separate columns) will always show all rows. For example:
|
||||
<li>Allowed filters include plain text matching, fuzzy search (<code>~</code>), exact match (<code>"</code>), wild card matches( <code>?</code> or <code>*</code>), regex (<code>/\d/g</code>), and logical and (<code>a && b</code>)/or (<code>a|b</code>) matches.<br><br></li>
|
||||
|
||||
<li>Not Match query - <strong>No longer a limitation!</strong> (<span class="version updated">v2.26.2</span>)
|
||||
<p>Try searching for <button type="button" data-column="all">!aaron</button></p>
|
||||
<del>A search for not matches (<code>!a</code>) is not allowed because tables that contain both numbers and text (in separate columns) will always show all rows. For example:
|
||||
<pre class="prettyprint lang-javascript">"Frank".search("a") // 2 (a match, so this row "may" be hidden)
|
||||
"Fred".search("a") // -1 (a not match! so this row will always show)
|
||||
"25".search("a") // -1 (a not match! so this row will always show)
|
||||
"1/1/2014".search("a") // -1 (a not match! so this row will always show)</pre>
|
||||
"1/1/2014".search("a") // -1 (a not match! so this row will always show)</pre></del>
|
||||
</li>
|
||||
<li>Allowed filters include plain text matching, fuzzy search (<code>~</code>), exact match (<code>"</code>), wild card matches( <code>?</code> or <code>*</code>), regex (<code>/\d/g</code>), and logical and (<code>a && b</code>)/or (<code>a|b</code>) matches.</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
<li>Setting this option should work properly with or without the column filters. The only issue you would have is if you triggered a search on the table using an array with undefined or null array values, like this:
|
||||
|
@ -461,7 +461,7 @@
|
||||
<li><span class="results">†</span> Filter widget (<span class="version updated">v2.25.9</span>):
|
||||
<ul>
|
||||
<li><a href="example-widget-filter.html">basic</a> (v2.0.18; <span class="version updated">v2.25.5</span>).</li>
|
||||
<li><a href="example-widget-filter-any-match.html">external option (match any column)</a> (<span class="version">v2.13.3</span>; <span class="version updated">v2.22.0</span>).</li>
|
||||
<li><a href="example-widget-filter-any-match.html">external option (match any column)</a> (<span class="version">v2.13.3</span>; <span class="version updated">v2.26.2</span>).</li>
|
||||
<li><a href="example-widget-filter-external-inputs.html">external inputs</a> (<span class="version">v2.14</span>; <span class="version updated">v2.18.0</span>).</li>
|
||||
<li><a href="example-widget-filter-custom.html">custom filter functions</a> (v2.3.6; <span class="version updated">v2.22.0</span>).</li>
|
||||
<li><a href="example-widget-filter-custom-search.html">custom search types</a> (<span class="version">v2.17.5</span>; <span class="version updated">v2.22.0</span>).</li>
|
||||
@ -4747,7 +4747,7 @@ $('table').trigger('search', false);</pre></div>
|
||||
<br>
|
||||
This option has been replaced by the <a href="#widget-filter-external"><code>filter_external</code></a> option.<br>
|
||||
<br>
|
||||
Show any rows that match a search query. If this option is <code>true</code> any column match will show that row; but there are limitations (<span class="version">v2.13.3</span>).<br>
|
||||
Show any rows that match a search query. If this option is <code>true</code> any column match will show that row; but <a href="example-widget-filter-any-match.html#limitations">there are limitations</a> (<span class="version">v2.13.3</span>).<br>
|
||||
<br>
|
||||
It is best if this <a href="#widget-filter-anymatch"><code>filter_anyMatch</code></a> option is used with a single search input as follows:
|
||||
<pre class="prettyprint lang-html"><input class="search" type="search">
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*! Widget: filter - updated 4/29/2016 (v2.25.9) *//*
|
||||
/*! Widget: filter - updated 5/16/2015 (v2.26.1) *//*
|
||||
* Requires tablesorter v2.8+ and jQuery 1.7+
|
||||
* by Rob Garrison
|
||||
*/
|
||||
@ -262,7 +262,11 @@
|
||||
return filter === '' ? true : $.trim( filter ) !== data.iExact;
|
||||
} else {
|
||||
indx = data.iExact.search( $.trim( filter ) );
|
||||
return filter === '' ? true : !( c.widgetOptions.filter_startsWith ? indx === 0 : indx >= 0 );
|
||||
return filter === '' ? true :
|
||||
// return true if not found
|
||||
data.anyMatch ? indx < 0 :
|
||||
// return false if found
|
||||
!( c.widgetOptions.filter_startsWith ? indx === 0 : indx >= 0 );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -1081,7 +1085,6 @@
|
||||
// look for multiple columns '1-3,4-6,8'
|
||||
tsf.multipleColumns( c, wo.filter_$anyMatch ) :
|
||||
[];
|
||||
|
||||
data.$cells = data.$row.children();
|
||||
if ( data.anyMatchFlag && columnIndex.length > 1 || data.anyMatchFilter ) {
|
||||
data.anyMatch = true;
|
||||
@ -1225,7 +1228,7 @@
|
||||
},
|
||||
vars = {
|
||||
// anyMatch really screws up with these types of filters
|
||||
noAnyMatch: [ 'range', 'notMatch', 'operators' ],
|
||||
noAnyMatch: [ 'range', 'operators' ],
|
||||
// cache filter variables that use ts.getColumnData in the main loop
|
||||
functions : [],
|
||||
excludeFilter : [],
|
||||
|
@ -197,7 +197,7 @@ jQuery(function($){
|
||||
wo = this.wo,
|
||||
$table = this.$table,
|
||||
table = this.table;
|
||||
expect(33);
|
||||
expect(34);
|
||||
|
||||
return QUnit.SequentialRunner(
|
||||
function(actions, assertions) {
|
||||
@ -248,6 +248,9 @@ jQuery(function($){
|
||||
).nextTask(
|
||||
function(){ ts.setFilters( table, ['', '!aa'] ); },
|
||||
function(){ assert.cacheCompare( table, 1, ['Brandon Clark', 'Peter', 'John', 'Clark', 'Bruce', 'Alex', 'Jim', 'Bruce Lee', 'Brenda Dexter', 'Dennis', 'Martha'], 'search not match; ensure search filtered gets cleared', true ); }
|
||||
).nextTask(
|
||||
function(){ ts.setFilters( table, ['', '', '', '', '', '', '', '', '!3'] ); },
|
||||
function(){ assert.cacheCompare( table, 0, [1, 11, 111, 9], 'search not any match', true ); }
|
||||
).nextTask(
|
||||
function(){ ts.setFilters( table, ['', 'br && c'] ); },
|
||||
function(){ assert.cacheCompare( table, 1, ['Brandon Clark', 'Bruce', 'Bruce Lee'], 'search and match', true ); }
|
||||
|
Loading…
Reference in New Issue
Block a user