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 ];
|
fxn = vars.functions[ columnIndex ];
|
||||||
filterMatched = null;
|
filterMatched = null;
|
||||||
if ( fxn ) {
|
if ( fxn ) {
|
||||||
if ( fxn === true ) {
|
if ( typeof fxn === 'function' ) {
|
||||||
// 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' ) {
|
|
||||||
// filter callback( exact cell content, parser normalized content,
|
// filter callback( exact cell content, parser normalized content,
|
||||||
// filter input value, column index, jQuery row object )
|
// filter input value, column index, jQuery row object )
|
||||||
filterMatched = fxn( data.exact, data.cache, data.filter, columnIndex, data.$row, c, data );
|
filterMatched = fxn( data.exact, data.cache, data.filter, columnIndex, data.$row, c, data );
|
||||||
@ -1269,8 +1263,18 @@
|
|||||||
result = filterMatched;
|
result = filterMatched;
|
||||||
// Look for match, and add child row data for matching
|
// Look for match, and add child row data for matching
|
||||||
} else {
|
} else {
|
||||||
txt = ( data.iExact + data.childRowText ).indexOf( tsf.parseFilter( c, data.iFilter, data ) );
|
// check fxn (filter-select in header) after filter types are checked
|
||||||
result = ( ( !wo.filter_startsWith && txt >= 0 ) || ( wo.filter_startsWith && txt === 0 ) );
|
// 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 {
|
} else {
|
||||||
result = filterMatched;
|
result = filterMatched;
|
||||||
|
@ -391,7 +391,7 @@ jQuery(function($){
|
|||||||
ts = this.ts,
|
ts = this.ts,
|
||||||
$table = this.$table,
|
$table = this.$table,
|
||||||
table = this.table;
|
table = this.table;
|
||||||
assert.expect(3);
|
assert.expect(4);
|
||||||
|
|
||||||
return QUnit.SequentialRunner(
|
return QUnit.SequentialRunner(
|
||||||
function(actions, assertions) {
|
function(actions, assertions) {
|
||||||
@ -400,10 +400,14 @@ jQuery(function($){
|
|||||||
).nextTask(
|
).nextTask(
|
||||||
function(){ ts.setFilters( table, ['abc 1'] ); },
|
function(){ ts.setFilters( table, ['abc 1'] ); },
|
||||||
function(){ assert.cacheCompare( table, 0, ['abc 1'], 'select exact search', true ); }
|
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(
|
).nextTask(
|
||||||
function(){
|
function(){
|
||||||
$table.find( '.filter-select' ).eq(0).addClass( 'filter-match' );
|
$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 ); }
|
function(){ assert.cacheCompare( table, 0, ['abc 1', 'abc 11', 'ABC 10'], 'select match search', true ); }
|
||||||
).nextTask(
|
).nextTask(
|
||||||
function(){ ts.setFilters( table, ['', '1'] ); },
|
function(){ ts.setFilters( table, ['', '1'] ); },
|
||||||
|
Loading…
Reference in New Issue
Block a user