Filter: return null from filter_selectSource to prevent select updates

From discussion in IRC with @alexweissman
This commit is contained in:
Rob Garrison 2017-05-26 13:26:36 -05:00
parent d095c63008
commit 17be0e31ea
2 changed files with 15 additions and 1 deletions

View File

@ -3337,7 +3337,7 @@ $('table').trigger('search', false);</pre></div>
<td>Function</td>
<td>null</td>
<td>
Filter widget: Include a function to return an array of values to be added to the column filter select (<span class="version">v2.16.0</span>; <span class="version updated">v2.24.4</span>).
Filter widget: Include a function to return an array of values to be added to the column filter select (<span class="version">v2.16.0</span>; <span class="version updated">v2.28.12</span>).
<div class="collapsible">
<br>
In <span class="version updated">v2.24.4</span>, this option will now accept an array of objects which can contain extra information for each option. Here is an example modified from the <a href="example-widget-filter-selectmenu.html">filter selectmenu demo</a>:
@ -3360,6 +3360,12 @@ $('table').trigger('search', false);</pre></div>
<li><span class="label warning">*NOTE*</span> because this example is providing a fixed select option source, it can not support "filter-onlyAvail" (only show available options after filtering).</li>
</ul>
<p>
In <span class="version updated">v2.28.12</span>, return <code>null</code> from a <code>filter_selectSource</code> function to prevent updates to the select options. Useful if you are updating the select options from outside of tablesorter.
<pre class="prettyprint lang-js">filter_selectSource : {
".filter-select" : function() { return null; }
}</pre>
</p>
<p>
In <span class="version updated">v2.27.7</span>, an option to have a descending sort applied to this data can be done by adding a <code>"filter-select-sort-desc"</code> to the header cell. Adding a <code>"filter-select-nosort"</code> class name to a header to prevent sorting has been available since v2.16.3.
</p>

View File

@ -1570,6 +1570,10 @@
} else if ( $.type( source ) === 'object' && fxn ) {
// custom select source function for a SPECIFIC COLUMN
arry = fxn( table, column, onlyAvail );
// abort - updating the selects from an external method
if (arry === null) {
return null;
}
}
if ( arry === false ) {
// fall back to original method
@ -1727,6 +1731,10 @@
// filter_selectSource or column data
if ( typeof arry === 'undefined' || arry === '' ) {
arry = tsf.getOptionSource( table, column, onlyAvail );
// abort, selects are updated by an external method
if (arry === null) {
return;
}
}
if ( $.isArray( arry ) ) {