mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Filter widget: Use new parser "parsed" parameter
This commit is contained in:
parent
a33fc74f57
commit
73c8f659cc
@ -47,6 +47,8 @@ $(function(){
|
||||
// return cell text, just in case
|
||||
return s;
|
||||
},
|
||||
// flag for filter widget (true = ALWAYS search parsed values; false = search cell text)
|
||||
parsed: false,
|
||||
// set type, either numeric or text
|
||||
type: 'text'
|
||||
});
|
||||
@ -77,6 +79,13 @@ $(function(){
|
||||
<p class="tip">
|
||||
<em>NOTE!</em>
|
||||
<ul>
|
||||
<li>In <span class="version">v2.15.0</span>, the <code>parsed</code> parameter
|
||||
<ul>
|
||||
<li>This parameter is a flag used by the filter widget.</li>
|
||||
<li>When <code>true</code>, the filter widget will only search through parsed data for matches.</li>
|
||||
<li>If <code>false</code> (default value), the filter widget will search through the cell text for matches.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>This method of writing custom parsers will NOT work with the original tablesorter 2.0.5b plugin because the format function does not consistently provide the <code>cell</code> and <code>cellIndex</code> parameters.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
@ -77,6 +77,14 @@ $(function() {
|
||||
<li>Use the <code>cellIndex</code> if the cells within columns contain different data - see this demo for an example.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>The <code>parsed</code> block (added <span class="version">v2.15.0</span>)
|
||||
<ul>
|
||||
<li>This parameter is a flag used by the filter widget.</li>
|
||||
<li>When <code>true</code>, the filter widget will only search through parsed data for matches.</li>
|
||||
<li>If <code>false</code> (default value), the filter widget will search through the cell text for matches.</li>
|
||||
<li>Currently, only the parsers for inputs, checkboxes and selects have this parameter set to <code>true</code>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>The <code>type</code> block sets the type of sort to use:
|
||||
<ul>
|
||||
<li>Set it to either <code>"text"</code> or <code>"numeric"</code>.</li>
|
||||
@ -107,6 +115,8 @@ $(function() {
|
||||
// (i.e. do something to get and/or modify your data, then return it)
|
||||
return s;
|
||||
},
|
||||
// flag for filter widget (true = ALWAYS search parsed values; false = search cell text)
|
||||
parsed: false,
|
||||
// set the type to either numeric or text (text uses a natural sort function
|
||||
// so it will work for everything, but numeric is faster for numbers
|
||||
type: 'numeric'
|
||||
|
@ -356,7 +356,7 @@
|
||||
</li>
|
||||
<li>How to:
|
||||
<ul>
|
||||
<li><a href="example-option-selectorsort.html">Using selectorSort option</a> (v2.4; <a href="#selectorsort"><code>selectorSort</code></a>)</li>
|
||||
<li><a href="example-option-selectorsort.html">Using selectorSort option</a> (<a href="#selectorsort"><code>selectorSort</code></a>; v2.4)</li>
|
||||
<li><a href="example-option-sort-key.html">Change the default multi-sorting key</a> (<a href="#sortmultisortkey"><code>sortMultiSortKey</code></a>)</li>
|
||||
<li><a href="example-option-custom-sort.html">Custom sort script</a> (<a href="#textsorter"><code>textSorter</code></a>; added v2.2; updated <span class="version updated">v2.12</span>)</li>
|
||||
<li><a href="example-locale-sort.html">Sorting Accented Characters</a> (<a href="#sortlocalecompare"><code>sortLocaleCompare</code></a>; v2.24; <a href="https://github.com/Mottie/tablesorter/wiki/Language">languages</a>)</li>
|
||||
@ -444,8 +444,8 @@
|
||||
|
||||
<h4>Parsers / Extracting Content</h4>
|
||||
<ul>
|
||||
<li><a href="example-parsers.html">Parser, writing your own</a> (<a href="#function-addparser"><code>addParser</code></a>)</li>
|
||||
<li><a href="example-parsers-advanced.html">Parser, writing your own, advanced use</a> (v2.1)</li>
|
||||
<li><a href="example-parsers.html">Parser, writing your own</a> (<a href="#function-addparser"><code>addParser</code></a>; <span class="updated version">v2.15.0</span>)</li>
|
||||
<li><a href="example-parsers-advanced.html">Parser, writing your own, advanced use</a> (v2.1; <span class="updated version">v2.15.0</span>)</li>
|
||||
<li><a href="example-option-text-extraction.html">Dealing with markup inside cells (<a href="#textextraction"><code>textExtraction</code></a> function)</a></li>
|
||||
</ul>
|
||||
|
||||
|
@ -852,9 +852,9 @@ ts.filter = {
|
||||
anyMatchNotAllowedTypes = [ 'range', 'notMatch', 'operators' ],
|
||||
// parse columns after formatter, in case the class is added at that point
|
||||
parsed = c.$headers.map(function(columnIndex) {
|
||||
return (ts.getData) ?
|
||||
return c.parsers[columnIndex].parsed || ( ts.getData ?
|
||||
ts.getData(c.$headers.filter('[data-column="' + columnIndex + '"]:last'), c.headers[columnIndex], 'filter') === 'parsed' :
|
||||
$(this).hasClass('filter-parsed');
|
||||
$(this).hasClass('filter-parsed') );
|
||||
}).get();
|
||||
if (c.debug) { time = new Date(); }
|
||||
for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
|
||||
|
@ -23,6 +23,7 @@
|
||||
format: function(s, table, cell) {
|
||||
return $(cell).find('input').val() || s;
|
||||
},
|
||||
parsed : true, // filter widget flag
|
||||
type: "text"
|
||||
});
|
||||
|
||||
@ -43,6 +44,7 @@
|
||||
// group headers - change it as desired
|
||||
return $c.length ? isChecked ? 'checked' : 'unchecked' : s;
|
||||
},
|
||||
parsed : true, // filter widget flag
|
||||
type: "text"
|
||||
});
|
||||
|
||||
@ -56,6 +58,7 @@
|
||||
format: function(s, table, cell) {
|
||||
return $(cell).find('select').val() || s;
|
||||
},
|
||||
parsed : true, // filter widget flag
|
||||
type: "text"
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user