diff --git a/js/widgets/widget-filter.js b/js/widgets/widget-filter.js
index 52510dfb..e3364a86 100644
--- a/js/widgets/widget-filter.js
+++ b/js/widgets/widget-filter.js
@@ -1209,7 +1209,8 @@
c.$headerIndexed[ columnIndex ].hasClass( 'filter-parsed' ) );
vars.functions[ columnIndex ] =
- ts.getColumnData( table, wo.filter_functions, columnIndex );
+ ts.getColumnData( table, wo.filter_functions, columnIndex ) ||
+ c.$headerIndexed[ columnIndex ].hasClass( 'filter-select' );
vars.defaultColFilter[ columnIndex ] =
ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '';
vars.excludeFilter[ columnIndex ] =
diff --git a/testing/testing-widgets.js b/testing/testing-widgets.js
index 405d364f..6ade7c33 100644
--- a/testing/testing-widgets.js
+++ b/testing/testing-widgets.js
@@ -45,31 +45,53 @@ jQuery(function($){
this.ts = $.tablesorter;
// filter widget table
- this.$table = $('#testblock').html('
' +
- '' +
- 'Rank | ' +
- 'First Name | ' +
- 'Last Name | ' +
- 'Age | ' +
- 'Total | ' +
- 'Discount | ' +
- 'Date | ' +
- 'Last Name2 | ' +
- '
' +
- '1 | Philip Aaron Wong | Johnson Sr Esq | 25 | $5.95 | 22% | Jun 26, 2004 7:22 AM | Johnson Sr Esq |
' +
- '11 | Aaron | Hibert | 12 | $2.99 | 5% | Aug 21, 2009 12:21 PM | Hibert |
' +
- '12 | Brandon Clark | Henry Jr | 51 | $42.29 | 18% | Oct 13, 2000 1:15 PM | Henry Jr |
' +
- '111 | Peter | Parker | 28 | $9.99 | 20% | Jul 6, 2006 8:14 AM | Parker |
' +
- '21 | John | Hood | 33 | $19.99 | 25% | Dec 10, 2002 5:14 AM | Hood |
' +
- '013 | Clark | Kent Sr. | 18 | $15.89 | 44% | Jan 12, 2003 11:14 AM | Kent Sr. |
' +
- '005 | Bruce | Almighty Esq | 45 | $153.19 | 44% | Jan 18, 2021 9:12 AM | Almighty Esq |
' +
- '10 | Alex | Dumass | 13 | $5.29 | 4% | Jan 8, 2012 5:11 PM | Dumass |
' +
- '16 | Jim | Franco | 24 | $14.19 | 14% | Jan 14, 2004 11:23 AM | Franco |
' +
- '166 | Bruce Lee | Evans | 22 | $13.19 | 11% | Jan 18, 2007 9:12 AM | Evans |
' +
- '100 | Brenda Dexter | McMasters | 18 | $55.20 | 15% | Feb 12, 2010 7:23 PM | McMasters |
' +
- '55 | Dennis | Bronson | 65 | $123.00 | | Jan 20, 2001 1:12 PM | Bronson |
' +
- '9 | Martha | delFuego | 25 | $22.09 | 17% | Jun 11, 2011 10:55 AM | delFuego |
' +
- '
').find('table');
+ if ( /\(table2\)/.test(assert.test.testName) ) {
+ this.$table = $('#testblock').html('' +
+ '' +
+ 'AlphaNumeric | ' +
+ 'Numeric | ' +
+ 'Animals | ' +
+ 'Sites | ' +
+ '
' +
+ 'abc | 1 | Koala | http://www.google.com |
' +
+ 'abc 1 | 234 | Ox | http://www.yahoo.com |
' +
+ 'abc 9 | 111 | Girafee | http://www.facebook.com |
' +
+ 'zyx 24 | 123 | Bison | http://www.whitehouse.gov/ |
' +
+ 'abc 11 | 3 | Chimp | http://www.ucla.edu/ |
' +
+ 'abc 2 | 56 | Elephant | http://www.wikipedia.org/ |
' +
+ 'abc 9 | 155 | Lion | http://www.nytimes.com/ |
' +
+ 'ABC 10 | 87 | Zebra | http://www.google.com |
' +
+ 'zyx 1 | 999 | Koala | http://www.mit.edu/ |
' +
+ 'zyx 12 | 0 | Llama | http://www.nasa.gov/ |
' +
+ '
').find('table');
+ } else {
+ this.$table = $('#testblock').html('' +
+ '' +
+ 'Rank | ' +
+ 'First Name | ' +
+ 'Last Name | ' +
+ 'Age | ' +
+ 'Total | ' +
+ 'Discount | ' +
+ 'Date | ' +
+ 'Last Name2 | ' +
+ '
' +
+ '1 | Philip Aaron Wong | Johnson Sr Esq | 25 | $5.95 | 22% | Jun 26, 2004 7:22 AM | Johnson Sr Esq |
' +
+ '11 | Aaron | Hibert | 12 | $2.99 | 5% | Aug 21, 2009 12:21 PM | Hibert |
' +
+ '12 | Brandon Clark | Henry Jr | 51 | $42.29 | 18% | Oct 13, 2000 1:15 PM | Henry Jr |
' +
+ '111 | Peter | Parker | 28 | $9.99 | 20% | Jul 6, 2006 8:14 AM | Parker |
' +
+ '21 | John | Hood | 33 | $19.99 | 25% | Dec 10, 2002 5:14 AM | Hood |
' +
+ '013 | Clark | Kent Sr. | 18 | $15.89 | 44% | Jan 12, 2003 11:14 AM | Kent Sr. |
' +
+ '005 | Bruce | Almighty Esq | 45 | $153.19 | 44% | Jan 18, 2021 9:12 AM | Almighty Esq |
' +
+ '10 | Alex | Dumass | 13 | $5.29 | 4% | Jan 8, 2012 5:11 PM | Dumass |
' +
+ '16 | Jim | Franco | 24 | $14.19 | 14% | Jan 14, 2004 11:23 AM | Franco |
' +
+ '166 | Bruce Lee | Evans | 22 | $13.19 | 11% | Jan 18, 2007 9:12 AM | Evans |
' +
+ '100 | Brenda Dexter | McMasters | 18 | $55.20 | 15% | Feb 12, 2010 7:23 PM | McMasters |
' +
+ '55 | Dennis | Bronson | 65 | $123.00 | | Jan 20, 2001 1:12 PM | Bronson |
' +
+ '9 | Martha | delFuego | 25 | $22.09 | 17% | Jun 11, 2011 10:55 AM | delFuego |
' +
+ '
').find('table');
+ }
+
this.table = this.$table[0];
this.init = false;
@@ -85,8 +107,8 @@ jQuery(function($){
filter_functions : {
'.last2' : true,
'.rank' : {
- "< 10" : function(e, n) { return n <= 10; },
- "> 10" : function(e, n) { return n > 10; }
+ '< 10' : function(e, n) { return n <= 10; },
+ '> 10' : function(e, n) { return n > 10; }
}
},
filter_selectSource : {
@@ -322,8 +344,31 @@ jQuery(function($){
opts.push( $.trim( $(this).text() ) );
});
assert.equal ( 'len=' + opts.length + ',' + opts.join(''), 'len=4,abcdefzyx', 'filter_selectSource set' );
-
});
+ QUnit.test( 'Filter: select & matching (table2)', function(assert) {
+ var self = this,
+ ts = this.ts,
+ $table = this.$table,
+ table = this.table;
+ expect(3);
+
+ return QUnit.SequentialRunner(
+ function(actions, assertions) {
+ return QUnit.assertOnEvent($table, 'filterEnd', actions, assertions);
+ }
+ ).nextTask(
+ function(){ ts.setFilters( table, ['abc 1'], true ); },
+ function(){ assert.cacheCompare( table, 0, ['abc 1'], 'select exact search', true ); }
+ ).nextTask(
+ function(){
+ $table.find( '.filter-select' ).eq(0).addClass( 'filter-match' );
+ ts.setFilters( table, [ 'abc 1' ], true ); },
+ function(){ assert.cacheCompare( table, 0, ['abc 1', 'abc 11', 'ABC 10'], 'select match search', true ); }
+ ).nextTask(
+ function(){ ts.setFilters( table, ['', '1'], true ); },
+ function(){ assert.cacheCompare( table, 1, [ 1, 111, 123, 155], 'select match seach', true ); }
+ ).promise();
+ });
});
diff --git a/testing/testing.js b/testing/testing.js
index 877f46b1..f14a3cd1 100644
--- a/testing/testing.js
+++ b/testing/testing.js
@@ -45,7 +45,7 @@ QUnit.SequentialRunner = function(runnerCreator){
next: function(runner) {
this.defer = this.defer.then( QUnit.deferredCallback(runner) );
return this;
- },
+ }
};
if (runnerCreator) {
result.nextTask = function(args) { // any argument list