mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Filter widget: make operator matching higher priority than exact matching. Fixes #465
This commit is contained in:
parent
d1a9f2ee22
commit
05d2075cef
@ -220,7 +220,7 @@ $(function(){
|
||||
</tbody>
|
||||
</table>
|
||||
<span class="bright">(1)</span> You cannot combine these operators with each other (except for the wildcards).<br>
|
||||
<span class="bright">(2)</span> The filter order (or precendence) of how searches are checked is as follows: <span class="smallcode">regex (<code>/\d/</code>) <strong>></strong> exact (<code>"</code>) <strong>></strong> not match (<code>!</code>) <strong>></strong> operators (<code>< <= >= ></code>) <strong>></strong> and (<code> AND </code>) <strong>></strong> range (<code> - </code>) <strong>></strong> wild/or (<code>?</code>, <code>*</code> and <code> OR </code>) <strong>></strong> fuzzy (<code>~</code>); so an exact match will override "and", "or" and "range" searches </span><br>
|
||||
<span class="bright">(2)</span> The filter order (or precendence) of how searches are checked is as follows: <span class="smallcode">regex (<code>/\d/</code>) <strong>></strong> operators (<code>< <= >= ></code>) <strong>></strong> exact (<code>"</code>) <strong>></strong> not match (<code>!</code>) <strong>></strong> and (<code> AND </code>) <strong>></strong> range (<code> - </code>) <strong>></strong> wild/or (<code>?</code>, <code>*</code> and <code> OR </code>) <strong>></strong> fuzzy (<code>~</code>); so an exact match will override "and", "or" and "range" searches </span> (*NOTE* order changed in <span class="version">v2.14.6</span>, operators prioritized before exact; see <a href="https://github.com/Mottie/tablesorter/issues/465">issue #465</a>) <br>
|
||||
<span class="bright">(3)</span> Logical "or" comparisons can now show exact matches (by default; <span class="version">v2.10.1</span>) or just match cell contents.<br>
|
||||
<span class="bright">(4)</span> In tablesorter <span class="version">v2.10</span>, comparisons can be made in date columns (if properly parsed).
|
||||
</li>
|
||||
|
@ -419,23 +419,6 @@ ts.filter = {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
// Look for quotes or equals to get an exact match; ignore type since iExact could be numeric
|
||||
exact: function( filter, iFilter, exact, iExact ) {
|
||||
/*jshint eqeqeq:false */
|
||||
if (ts.filter.regex.exact.test(iFilter)) {
|
||||
return iFilter.replace(ts.filter.regex.exact, '') == iExact;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
// Look for a not match
|
||||
notMatch: function( filter, iFilter, exact, iExact, cached, index, table, wo ) {
|
||||
if ( /^\!/.test(iFilter) ) {
|
||||
iFilter = iFilter.replace('!', '');
|
||||
var indx = iExact.search( $.trim(iFilter) );
|
||||
return iFilter === '' ? true : !(wo.filter_startsWith ? indx === 0 : indx >= 0);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
// Look for operators >, >=, < or <=
|
||||
operators: function( filter, iFilter, exact, iExact, cached, index, table, wo, parsed ) {
|
||||
if ( /^[<>]=?/.test(iFilter) ) {
|
||||
@ -462,6 +445,23 @@ ts.filter = {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
// Look for quotes or equals to get an exact match; ignore type since iExact could be numeric
|
||||
exact: function( filter, iFilter, exact, iExact ) {
|
||||
/*jshint eqeqeq:false */
|
||||
if (ts.filter.regex.exact.test(iFilter)) {
|
||||
return iFilter.replace(ts.filter.regex.exact, '') == iExact;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
// Look for a not match
|
||||
notMatch: function( filter, iFilter, exact, iExact, cached, index, table, wo ) {
|
||||
if ( /^\!/.test(iFilter) ) {
|
||||
iFilter = iFilter.replace('!', '');
|
||||
var indx = iExact.search( $.trim(iFilter) );
|
||||
return iFilter === '' ? true : !(wo.filter_startsWith ? indx === 0 : indx >= 0);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
// Look for an AND or && operator (logical and)
|
||||
and : function( filter, iFilter, exact, iExact ) {
|
||||
if ( /\s+(AND|&&)\s+/g.test(filter) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user