Filter: don't save column specific any matches to storage

This commit is contained in:
Mottie 2015-05-12 12:00:30 -05:00
parent e8f0a07f60
commit eadfe2980b
2 changed files with 11 additions and 7 deletions

View File

@ -18,7 +18,8 @@
<!-- 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-storage.js"></script>
<script src="../js/widgets/widget-filter.js"></script>
<script id="js">$(function() {
@ -72,6 +73,7 @@
<h3><a href="#">Notes</a></h3>
<div>
<ul>
<li>In <span class="version">v2.21.6</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>
<li>In <span class="version">v2.17.8</span>, added a default fuzzy search to the "First Name" column.</li>
@ -79,7 +81,7 @@
<li>In <span class="version">v2.15</span>
<ul>
<li>The <a class="alert" href="index.html#widget-filter-any-match"><code>filter_anyMatch</code></a> has been <span class="label alert">removed</span> (added <span class="version">v2.13.3</span>; removed in v2.15)</li>
<li>A new option <code>filter_external</code> has been added. It is set to a jQuery selector string (<code>'.search'</code>) or jQuery object (<code>$('.search')</code>) targetting an external input.</li>
<li>A new option <code>filter_external</code> has been added. It is set to a jQuery selector string (<code>'.search'</code>) or jQuery object (<code>$('.search')</code>) targeting an external input.</li>
<li>So now a table can include <em>both</em> a filter row (<code>filter_columnFilters</code> is <code>true</code>, i.e. the internal table filters) and any number of external search inputs (as set by the <code>filter_external</code> option).</li>
<li>The external search results must have a <code>data-column="#"</code> attribute set, where <code>#</code> is the index of the column (zero-based) that the input targets, to have an input search all table content, set the data column attribute to <code>"all"</code> to match any column.</li>
<li>The <a href="index.html#function-bindsearch"><code>$.tablesorter.bindSearch</code> function</a> (<a href="example-widget-filter-external-inputs.html">see demo</a>) does exactly the same thing as the <code>filter_external</code> option. The major difference is seen when using ajax to populate the table, the initial filter values can be set before tablesorter initialization when using teh <code>filter_external</code> option; whereas, the bind search function can not set initial filter values and is usually executed after tablesorter initialization.</li>
@ -107,7 +109,7 @@
<li>This column specific anyMatch does not support using an OR column search like <code>1:5|7:12</code> </li>
</ul>
<p></p>
<span class="label warning">* NOTE *</span> When a AnyMatch search of this type is active, it adds filter queries to specific columns, so if the filters are saved and you reload the page, the specified <em>column filters will become populated</em> along with the AnyMatch search.
<span class="label label-info">* NOTE *</span> Fixed in <span class="version">v2.21.6</span>. <del>When a AnyMatch search of this type is active, it adds filter queries to specific columns, so if the filters are saved and you reload the page, the specified <em>column filters will become populated</em> along with the AnyMatch search</del>.
</li>
</ul>
</div>

View File

@ -800,6 +800,7 @@ ts.filter = {
childRow, lastSearch, hasSelect, matches, result, showRow, time, val, indx,
notFiltered, searchFiltered, filterMatched, excludeMatch, fxn, ffxn,
query, injected, res, id,
storedFilters = $.extend( [], filters ),
regex = ts.filter.regex,
c = table.config,
wo = c.widgetOptions,
@ -840,7 +841,7 @@ ts.filter = {
c.filteredRows = 0;
c.totalRows = 0;
// combindedFilters are undefined on init
combinedFilters = (filters || []).join('');
combinedFilters = (storedFilters || []).join('');
for (tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++ ) {
$tbody = ts.processTbody(table, c.$tbodies.eq(tbodyIndex), true);
@ -1088,10 +1089,11 @@ ts.filter = {
ts.processTbody(table, $tbody, false);
}
c.lastCombinedFilter = combinedFilters; // save last search
c.lastSearch = filters;
c.$table.data('lastSearch', filters);
// don't save "filters" directly since it may have altered (AnyMatch column searches)
c.lastSearch = storedFilters;
c.$table.data('lastSearch', storedFilters);
if (wo.filter_saveFilters && ts.storage) {
ts.storage( table, 'tablesorter-filters', filters );
ts.storage( table, 'tablesorter-filters', storedFilters );
}
if (c.debug) {
ts.benchmark("Completed filter widget search", time);