mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Filter: select searches process filter type, then exactly match
Previously only exact matches were performed by default, filter types were ignored. This broke the filter + jQuery UI selectmenu demo
This commit is contained in:
parent
9a360b62a8
commit
7385ed4bf1
@ -1244,13 +1244,7 @@
|
||||
fxn = vars.functions[ columnIndex ];
|
||||
filterMatched = null;
|
||||
if ( fxn ) {
|
||||
if ( fxn === true ) {
|
||||
// default selector uses exact match unless 'filter-match' class is found
|
||||
filterMatched = data.isMatch ?
|
||||
// data.iExact may be a number
|
||||
( '' + data.iExact ).search( data.iFilter ) >= 0 :
|
||||
data.filter === data.exact;
|
||||
} else if ( typeof fxn === 'function' ) {
|
||||
if ( typeof fxn === 'function' ) {
|
||||
// filter callback( exact cell content, parser normalized content,
|
||||
// filter input value, column index, jQuery row object )
|
||||
filterMatched = fxn( data.exact, data.cache, data.filter, columnIndex, data.$row, c, data );
|
||||
@ -1268,10 +1262,20 @@
|
||||
if ( filterMatched !== null ) {
|
||||
result = filterMatched;
|
||||
// Look for match, and add child row data for matching
|
||||
} else {
|
||||
// check fxn (filter-select in header) after filter types are checked
|
||||
// without this, the filter + jQuery UI selectmenu demo was breaking
|
||||
if ( fxn === true ) {
|
||||
// default selector uses exact match unless 'filter-match' class is found
|
||||
result = data.isMatch ?
|
||||
// data.iExact may be a number
|
||||
( '' + data.iExact ).search( data.iFilter ) >= 0 :
|
||||
data.filter === data.exact;
|
||||
} else {
|
||||
txt = ( data.iExact + data.childRowText ).indexOf( tsf.parseFilter( c, data.iFilter, data ) );
|
||||
result = ( ( !wo.filter_startsWith && txt >= 0 ) || ( wo.filter_startsWith && txt === 0 ) );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = filterMatched;
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ jQuery(function($){
|
||||
ts = this.ts,
|
||||
$table = this.$table,
|
||||
table = this.table;
|
||||
assert.expect(3);
|
||||
assert.expect(4);
|
||||
|
||||
return QUnit.SequentialRunner(
|
||||
function(actions, assertions) {
|
||||
@ -400,10 +400,14 @@ jQuery(function($){
|
||||
).nextTask(
|
||||
function(){ ts.setFilters( table, ['abc 1'] ); },
|
||||
function(){ assert.cacheCompare( table, 0, ['abc 1'], 'select exact search', true ); }
|
||||
).nextTask(
|
||||
function(){ ts.setFilters( table, ['/abc\\s1$/'] ); },
|
||||
function(){ assert.cacheCompare( table, 0, ['abc 1'], 'select exact search using regex', true ); }
|
||||
).nextTask(
|
||||
function(){
|
||||
$table.find( '.filter-select' ).eq(0).addClass( 'filter-match' );
|
||||
ts.setFilters( table, [ 'abc 1' ] ); },
|
||||
ts.setFilters( table, [ 'abc 1' ] );
|
||||
},
|
||||
function(){ assert.cacheCompare( table, 0, ['abc 1', 'abc 11', 'ABC 10'], 'select match search', true ); }
|
||||
).nextTask(
|
||||
function(){ ts.setFilters( table, ['', '1'] ); },
|
||||
|
Loading…
Reference in New Issue
Block a user