mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Filter: force cache build on initial search when delayInit true. Fixes #678
This commit is contained in:
parent
4ef7bcd5a8
commit
4f29e36f12
@ -475,7 +475,7 @@
|
||||
<li><a href="example-widget-editable.html">Content Editable widget</a> (v2.9; <span class="version updated">v2.13.2</span>).</li>
|
||||
<li><span class="results">†</span> Filter Widget (<span class="version updated">v2.17.4</span>):
|
||||
<ul>
|
||||
<li><a href="example-widget-filter.html">basic</a> (v2.0.18; <span class="version updated">v2.17.1</span>)</li>
|
||||
<li><a href="example-widget-filter.html">basic</a> (v2.0.18; <span class="version updated">v2.17.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.15</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.15</span>)</li>
|
||||
<li><a href="example-widget-filter-custom.html">custom</a> (v2.3.6; <span class="version updated">v2.10.1</span>)</li>
|
||||
@ -496,9 +496,9 @@
|
||||
<br><br>
|
||||
</li>
|
||||
|
||||
<li>Pager plugin (<a href="example-pager.html">basic</a> & <a href="example-pager-ajax.html">ajax</a> demos; <span class="version updated">v2.17.4</span>).</li>
|
||||
<li>Pager plugin (<a href="example-pager.html">basic</a> & <a href="example-pager-ajax.html">ajax</a> demos; <span class="version updated">v2.17.5</span>).</li>
|
||||
<li>
|
||||
Pager widget (<a href="example-widget-pager.html">basic</a> & <a href="example-widget-pager-ajax.html">ajax</a> demos) (<span class="version">v2.12</span>; <span class="version updated">v2.17.4</span>).<br>
|
||||
Pager widget (<a href="example-widget-pager.html">basic</a> & <a href="example-widget-pager-ajax.html">ajax</a> demos) (<span class="version">v2.12</span>; <span class="version updated">v2.17.5</span>).<br>
|
||||
<br>
|
||||
</li>
|
||||
|
||||
|
@ -592,7 +592,7 @@ ts.filter = {
|
||||
}
|
||||
|
||||
c.$table.bind('addRows updateCell update updateRows updateComplete appendCache filterReset filterEnd search '.split(' ').join(c.namespace + 'filter '), function(event, filter) {
|
||||
c.$table.find('.' + ts.css.filterRow).toggle( !(wo.filter_hideEmpty && $.isEmptyObject(c.cache)) ); // fixes #450
|
||||
c.$table.find('.' + ts.css.filterRow).toggle( !(wo.filter_hideEmpty && $.isEmptyObject(c.cache) && !(c.delayInit && event.type === 'appendCache')) ); // fixes #450
|
||||
if ( !/(search|filter)/.test(event.type) ) {
|
||||
event.stopPropagation();
|
||||
ts.filter.buildDefault(table, true);
|
||||
@ -689,8 +689,10 @@ ts.filter = {
|
||||
var wo = this.config.widgetOptions;
|
||||
filters = ts.filter.setDefaults(table, c, wo) || [];
|
||||
if (filters.length) {
|
||||
ts.setFilters(table, filters, true);
|
||||
// ts.filter.checkFilters(table, filters);
|
||||
// prevent delayInit from triggering a cache build if filters are empty
|
||||
if ( !(c.delayInit && filters.join('') === '') ) {
|
||||
ts.setFilters(table, filters, true);
|
||||
}
|
||||
}
|
||||
c.$table.trigger('filterFomatterUpdate');
|
||||
if (!wo.filter_initialized) {
|
||||
@ -852,7 +854,15 @@ ts.filter = {
|
||||
filters = (filterArray) ? filter : ts.getFilters(table, true),
|
||||
combinedFilters = (filters || []).join(''); // combined filter values
|
||||
// prevent errors if delay init is set
|
||||
if ($.isEmptyObject(c.cache)) { return; }
|
||||
if ($.isEmptyObject(c.cache)) {
|
||||
// update cache if delayInit set & pager has initialized (after user initiates a search)
|
||||
if (c.delayInit && c.pager && c.pager.initialized) {
|
||||
c.$table.trigger('updateCache', [function(){
|
||||
ts.filter.checkFilters(table, false, skipFirst);
|
||||
}] );
|
||||
}
|
||||
return;
|
||||
}
|
||||
// add filter array back into inputs
|
||||
if (filterArray) {
|
||||
ts.setFilters( table, filters, false, skipFirst !== true );
|
||||
|
Loading…
Reference in New Issue
Block a user