mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-10-08 13:44:18 +00:00
Filter: add filter_excludeFilter option
This commit is contained in:
parent
d0ed9d1fa7
commit
356ee47026
@ -64,12 +64,19 @@
|
|||||||
// this option can either be a string (class applied to all filters) or an array (class applied to indexed filter)
|
// this option can either be a string (class applied to all filters) or an array (class applied to indexed filter)
|
||||||
filter_cssFilter : '', // or []
|
filter_cssFilter : '', // or []
|
||||||
|
|
||||||
|
// add a default column filter type "~{query}" to make fuzzy searches default;
|
||||||
|
// "{q1} AND {q2}" to make all searches use a logical AND.
|
||||||
|
filter_defaultFilter : {},
|
||||||
|
|
||||||
|
// filters to exclude, per column
|
||||||
|
filter_excludeFilter : {},
|
||||||
|
|
||||||
// jQuery selector (or object) pointing to an input to be used to match the contents of any column
|
// jQuery selector (or object) pointing to an input to be used to match the contents of any column
|
||||||
// please refer to the filter-any-match demo for limitations - new in v2.15
|
// please refer to the filter-any-match demo for limitations - new in v2.15
|
||||||
filter_external : '',
|
filter_external : '',
|
||||||
|
|
||||||
// class added to filtered rows (rows that are not showing); needed by pager plugin
|
// class added to filtered rows (rows that are not showing); needed by pager plugin
|
||||||
filter_filteredRow : 'filtered',
|
filter_filteredRow : 'filtered',
|
||||||
|
|
||||||
// add custom filter elements to the filter row
|
// add custom filter elements to the filter row
|
||||||
// see the filter formatter demos for more specifics
|
// see the filter formatter demos for more specifics
|
||||||
@ -104,7 +111,7 @@
|
|||||||
|
|
||||||
// if true, server-side filtering should be performed because client-side filtering will be disabled, but
|
// if true, server-side filtering should be performed because client-side filtering will be disabled, but
|
||||||
// the ui and events will still be used.
|
// the ui and events will still be used.
|
||||||
filter_serversideFiltering: false,
|
filter_serversideFiltering : false,
|
||||||
|
|
||||||
// Set this option to true to use the filter to find text from the start of the column
|
// Set this option to true to use the filter to find text from the start of the column
|
||||||
// So typing in "a" will find "albert" but not "frank", both have a's; default is false
|
// So typing in "a" will find "albert" but not "frank", both have a's; default is false
|
||||||
@ -295,8 +302,20 @@ $(function(){
|
|||||||
<td>this option contains the name of the data-attribute which contains the default (starting) filter value.</td>
|
<td>this option contains the name of the data-attribute which contains the default (starting) filter value.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr id="filter-defaultfilter">
|
||||||
|
<td><span class="permalink">filter_defaultFilter</span></td>
|
||||||
|
<td>{ }</td>
|
||||||
|
<td>Set a default filter for a set column (<span class="version">v2.17.8</span>).</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr id="filter-excludefilter">
|
||||||
|
<td><span class="permalink">filter_excludeFilter</span></td>
|
||||||
|
<td>{ }</td>
|
||||||
|
<td>Set a column to exclude the chosen filter types (range, exact, notMatch, etc) (<span class="version">v2.17.8</span>).</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr id="filter-external">
|
<tr id="filter-external">
|
||||||
<td><span class="permalink">filter_external</span></td>
|
<td><a href="#" class="permalink">filter_external</a></td>
|
||||||
<td>''</td>
|
<td>''</td>
|
||||||
<td>
|
<td>
|
||||||
Set to a jQuery selector (or object) pointing to an input to be used to match the contents of any column (<span class="version">v2.15</span>).
|
Set to a jQuery selector (or object) pointing to an input to be used to match the contents of any column (<span class="version">v2.15</span>).
|
||||||
@ -405,12 +424,24 @@ $(function(){
|
|||||||
<td>Typing delay in milliseconds before starting a search.</td>
|
<td>Typing delay in milliseconds before starting a search.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr id="filter-search-filtered">
|
||||||
|
<td><span class="permalink">filter_searchFiltered</span></td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>Allow searching through already filtered rows in special circumstances; will speed up searching in large tables if <code>true</code>.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr id="filter-select-source">
|
<tr id="filter-select-source">
|
||||||
<td><span class="permalink">filter_selectSource</span></td>
|
<td><span class="permalink">filter_selectSource</span></td>
|
||||||
<td>null</td>
|
<td>null</td>
|
||||||
<td>Include a function to return an array of values to be added to the column filter select (<span class="version">v2.16.0</span>).</td>
|
<td>Include a function to return an array of values to be added to the column filter select (<span class="version">v2.16.0</span>).</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr id="filter-select-source-separator">
|
||||||
|
<td><span class="permalink">filter_selectSourceSeparator</span></td>
|
||||||
|
<td>null</td>
|
||||||
|
<td><code>filter_selectSource</code> array text left of the separator is added to the option value, right into the option text.</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr id="filter-serverside-filtering">
|
<tr id="filter-serverside-filtering">
|
||||||
<td><span class="permalink">filter_serversideFiltering</span></td>
|
<td><span class="permalink">filter_serversideFiltering</span></td>
|
||||||
<td>false</td>
|
<td>false</td>
|
||||||
|
@ -1624,7 +1624,9 @@ $(function(){
|
|||||||
// data attribute in the header cell that contains the default filter value
|
// data attribute in the header cell that contains the default filter value
|
||||||
filter_defaultAttrib : 'data-value',
|
filter_defaultAttrib : 'data-value',
|
||||||
// add a default column filter type "~{query}" to make fuzzy searches default; "{q1} AND {q2}" to make all searches use a logical AND.
|
// add a default column filter type "~{query}" to make fuzzy searches default; "{q1} AND {q2}" to make all searches use a logical AND.
|
||||||
filter_defaultFilter : [],
|
filter_defaultFilter : {},
|
||||||
|
// filters to exclude, per column
|
||||||
|
filter_excludeFilter : {},
|
||||||
// jQuery selector string (or jQuery object) of external search inputs
|
// jQuery selector string (or jQuery object) of external search inputs
|
||||||
filter_external : '',
|
filter_external : '',
|
||||||
// class added to filtered rows; needed by pager plugin
|
// class added to filtered rows; needed by pager plugin
|
||||||
@ -2094,6 +2096,47 @@ $(function(){
|
|||||||
<td><a href="example-widget-filter-any-match.html">Example</a></td>
|
<td><a href="example-widget-filter-any-match.html">Example</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr id="widget-filter-exclude-filter">
|
||||||
|
<td><a href="#" class="permalink">filter_excludeFilter</a></td>
|
||||||
|
<td>Object</td>
|
||||||
|
<td>{ }</td>
|
||||||
|
<td>Additional CSS class applied to each filter (<span class="version">v2.17.8</span>).
|
||||||
|
Filter widget: Exclude a filter type(s) for a column.
|
||||||
|
<div class="collapsible">
|
||||||
|
<br>
|
||||||
|
Use the <a href="#widget-excludefilter"><code>filter_excludeFilter</code></a> option as follows:
|
||||||
|
<pre class="prettyprint lang-js">$(function(){
|
||||||
|
$("table").tablesorter({
|
||||||
|
widgets: ["filter"],
|
||||||
|
widgetOptions : {
|
||||||
|
|
||||||
|
filter_excludeFilter : {
|
||||||
|
// target a column by class name or column index (zero-based)
|
||||||
|
'.title' : 'range',
|
||||||
|
|
||||||
|
// separate multiple filter types using spaces
|
||||||
|
2 : 'range notMatch exact'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});</pre>
|
||||||
|
Exclusion names must be separated by a comma. Here is a full list of filter type names:
|
||||||
|
<ul>
|
||||||
|
<li><code>and</code> - logical <code>" AND "</code> or <code> && </code> type filter.</li>
|
||||||
|
<li><code>exact</code> - exact match (using <code>"</code> or <code>=</code>).</li>
|
||||||
|
<li><code>fuzzy</code> - fuzzy match (<code>~</code>)</li>
|
||||||
|
<li><code>notMatch</code> - not match (<code>!</code> or <code>!=</code>)</li>
|
||||||
|
<li><code>operators</code> - comparison filters (<code>< <= >= ></code>)</li>
|
||||||
|
<li><code>range</code> - range (<code> - </code> or <code> to </code>)</li>
|
||||||
|
<li><code>regex</code> - regex (<code>/\d/</code>)</li>
|
||||||
|
<li><code>wild</code> - wild card matching (<code>?</code> for single characters, <code>*</code> for multiple characters not including spaces, or <code>|</code> or <code> OR </code> for a logical OR.</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr id="widget-filter-external">
|
<tr id="widget-filter-external">
|
||||||
<td><a href="#" class="permalink">filter_external</a></td>
|
<td><a href="#" class="permalink">filter_external</a></td>
|
||||||
<td>String</td>
|
<td>String</td>
|
||||||
|
@ -354,7 +354,8 @@ ts.addWidget({
|
|||||||
filter_childRows : false, // if true, filter includes child row content in the search
|
filter_childRows : false, // if true, filter includes child row content in the search
|
||||||
filter_columnFilters : true, // if true, a filter will be added to the top of each table column
|
filter_columnFilters : true, // if true, a filter will be added to the top of each table column
|
||||||
filter_cssFilter : '', // css class name added to the filter row & each input in the row (tablesorter-filter is ALWAYS added)
|
filter_cssFilter : '', // css class name added to the filter row & each input in the row (tablesorter-filter is ALWAYS added)
|
||||||
filter_defaultFilter : [], // add a default column filter type "~{query}" to make fuzzy searches default; "{q1} AND {q2}" to make all searches use a logical AND.
|
filter_defaultFilter : {}, // add a default column filter type "~{query}" to make fuzzy searches default; "{q1} AND {q2}" to make all searches use a logical AND.
|
||||||
|
filter_excludeFilter : {}, // filters to exclude, per column
|
||||||
filter_external : '', // jQuery selector string (or jQuery object) of external filters
|
filter_external : '', // jQuery selector string (or jQuery object) of external filters
|
||||||
filter_filteredRow : 'filtered', // class added to filtered rows; needed by pager plugin
|
filter_filteredRow : 'filtered', // class added to filtered rows; needed by pager plugin
|
||||||
filter_formatter : null, // add custom filter elements to the filter row
|
filter_formatter : null, // add custom filter elements to the filter row
|
||||||
@ -1033,7 +1034,7 @@ ts.filter = {
|
|||||||
if (table.config.lastCombinedFilter === combinedFilters || table.config.widgetOptions.filter_initializing) { return; }
|
if (table.config.lastCombinedFilter === combinedFilters || table.config.widgetOptions.filter_initializing) { return; }
|
||||||
var len, $rows, rowIndex, tbodyIndex, $tbody, $cells, columnIndex,
|
var len, $rows, rowIndex, tbodyIndex, $tbody, $cells, columnIndex,
|
||||||
childRow, lastSearch, matches, result, showRow, time, val, indx,
|
childRow, lastSearch, matches, result, showRow, time, val, indx,
|
||||||
notFiltered, searchFiltered, filterMatched, fxn, ffxn,
|
notFiltered, searchFiltered, filterMatched, excludeMatch, fxn, ffxn,
|
||||||
regex = ts.filter.regex,
|
regex = ts.filter.regex,
|
||||||
c = table.config,
|
c = table.config,
|
||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
@ -1181,6 +1182,10 @@ ts.filter = {
|
|||||||
for (columnIndex = 0; columnIndex < c.columns; columnIndex++) {
|
for (columnIndex = 0; columnIndex < c.columns; columnIndex++) {
|
||||||
data.filter = filters[columnIndex];
|
data.filter = filters[columnIndex];
|
||||||
data.index = columnIndex;
|
data.index = columnIndex;
|
||||||
|
|
||||||
|
// filter types to exclude, per column
|
||||||
|
excludeMatch = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s*,\s*/);
|
||||||
|
|
||||||
// ignore if filter is empty or disabled
|
// ignore if filter is empty or disabled
|
||||||
if (data.filter) {
|
if (data.filter) {
|
||||||
data.cache = data.cacheArray[columnIndex];
|
data.cache = data.cacheArray[columnIndex];
|
||||||
@ -1225,10 +1230,12 @@ ts.filter = {
|
|||||||
// cycle through the different filters
|
// cycle through the different filters
|
||||||
// filters return a boolean or null if nothing matches
|
// filters return a boolean or null if nothing matches
|
||||||
$.each(ts.filter.types, function(type, typeFunction) {
|
$.each(ts.filter.types, function(type, typeFunction) {
|
||||||
matches = typeFunction( c, data );
|
if ($.inArray(type, excludeMatch) < 0) {
|
||||||
if (matches !== null) {
|
matches = typeFunction( c, data );
|
||||||
filterMatched = matches;
|
if (matches !== null) {
|
||||||
return false;
|
filterMatched = matches;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (filterMatched !== null) {
|
if (filterMatched !== null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user