mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Filter: allow setting filter_selectSource with filter_functions
See http://jsfiddle.net/Mottie/856bzzeL/117/
This commit is contained in:
parent
cd98f306bb
commit
cfc18ac71b
19
dist/js/jquery.tablesorter.combined.js
vendored
19
dist/js/jquery.tablesorter.combined.js
vendored
@ -2855,6 +2855,12 @@ ts.filter = {
|
||||
}
|
||||
}
|
||||
c.$table.find('thead').find('select.' + tscss.filter + '[data-column="' + column + '"]').append(options);
|
||||
txt = wo.filter_selectSource;
|
||||
fxn = $.isFunction(txt) ? true : ts.getColumnData( table, txt, column );
|
||||
if (fxn) {
|
||||
// updating so the extra options are appended
|
||||
ts.filter.buildSelect(c.table, column, '', true, $header.hasClass(wo.filter_onlyAvail));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3514,19 +3520,20 @@ ts.filter = {
|
||||
fxn = wo.filter_indexed.functions[ columnIndex ];
|
||||
$cell = c.$headerIndexed[columnIndex];
|
||||
hasSelect = $cell.hasClass('filter-select');
|
||||
filterMatched = null;
|
||||
if ( fxn || ( hasSelect && val ) ) {
|
||||
if (fxn === true || hasSelect) {
|
||||
// default selector uses exact match unless "filter-match" class is found
|
||||
result = ($cell.hasClass('filter-match')) ? data.iExact.search(data.iFilter) >= 0 : data.filter === data.exact;
|
||||
filterMatched = ($cell.hasClass('filter-match')) ? data.iExact.search(data.iFilter) >= 0 : data.filter === data.exact;
|
||||
} else if (typeof fxn === 'function') {
|
||||
// filter callback( exact cell content, parser normalized content, filter input value, column index, jQuery row object )
|
||||
result = fxn(data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
filterMatched = fxn(data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
} else if (typeof fxn[ffxn || data.filter] === 'function') {
|
||||
// selector option function
|
||||
result = fxn[ffxn || data.filter](data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
filterMatched = fxn[ffxn || data.filter](data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
}
|
||||
} else {
|
||||
filterMatched = null;
|
||||
}
|
||||
if (filterMatched === null) {
|
||||
// cycle through the different filters
|
||||
// filters return a boolean or null if nothing matches
|
||||
$.each(ts.filter.types, function(type, typeFunction) {
|
||||
@ -3545,6 +3552,8 @@ ts.filter = {
|
||||
data.exact = (data.iExact + data.childRowText).indexOf( ts.filter.parseFilter(c, data.iFilter, columnIndex, data.parsed[columnIndex]) );
|
||||
result = ( (!wo.filter_startsWith && data.exact >= 0) || (wo.filter_startsWith && data.exact === 0) );
|
||||
}
|
||||
} else {
|
||||
result = filterMatched;
|
||||
}
|
||||
showRow = (result) ? showRow : false;
|
||||
}
|
||||
|
4
dist/js/jquery.tablesorter.combined.min.js
vendored
4
dist/js/jquery.tablesorter.combined.min.js
vendored
File diff suppressed because one or more lines are too long
19
dist/js/jquery.tablesorter.widgets.js
vendored
19
dist/js/jquery.tablesorter.widgets.js
vendored
@ -726,6 +726,12 @@ ts.filter = {
|
||||
}
|
||||
}
|
||||
c.$table.find('thead').find('select.' + tscss.filter + '[data-column="' + column + '"]').append(options);
|
||||
txt = wo.filter_selectSource;
|
||||
fxn = $.isFunction(txt) ? true : ts.getColumnData( table, txt, column );
|
||||
if (fxn) {
|
||||
// updating so the extra options are appended
|
||||
ts.filter.buildSelect(c.table, column, '', true, $header.hasClass(wo.filter_onlyAvail));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1385,19 +1391,20 @@ ts.filter = {
|
||||
fxn = wo.filter_indexed.functions[ columnIndex ];
|
||||
$cell = c.$headerIndexed[columnIndex];
|
||||
hasSelect = $cell.hasClass('filter-select');
|
||||
filterMatched = null;
|
||||
if ( fxn || ( hasSelect && val ) ) {
|
||||
if (fxn === true || hasSelect) {
|
||||
// default selector uses exact match unless "filter-match" class is found
|
||||
result = ($cell.hasClass('filter-match')) ? data.iExact.search(data.iFilter) >= 0 : data.filter === data.exact;
|
||||
filterMatched = ($cell.hasClass('filter-match')) ? data.iExact.search(data.iFilter) >= 0 : data.filter === data.exact;
|
||||
} else if (typeof fxn === 'function') {
|
||||
// filter callback( exact cell content, parser normalized content, filter input value, column index, jQuery row object )
|
||||
result = fxn(data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
filterMatched = fxn(data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
} else if (typeof fxn[ffxn || data.filter] === 'function') {
|
||||
// selector option function
|
||||
result = fxn[ffxn || data.filter](data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
filterMatched = fxn[ffxn || data.filter](data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
}
|
||||
} else {
|
||||
filterMatched = null;
|
||||
}
|
||||
if (filterMatched === null) {
|
||||
// cycle through the different filters
|
||||
// filters return a boolean or null if nothing matches
|
||||
$.each(ts.filter.types, function(type, typeFunction) {
|
||||
@ -1416,6 +1423,8 @@ ts.filter = {
|
||||
data.exact = (data.iExact + data.childRowText).indexOf( ts.filter.parseFilter(c, data.iFilter, columnIndex, data.parsed[columnIndex]) );
|
||||
result = ( (!wo.filter_startsWith && data.exact >= 0) || (wo.filter_startsWith && data.exact === 0) );
|
||||
}
|
||||
} else {
|
||||
result = filterMatched;
|
||||
}
|
||||
showRow = (result) ? showRow : false;
|
||||
}
|
||||
|
4
dist/js/jquery.tablesorter.widgets.min.js
vendored
4
dist/js/jquery.tablesorter.widgets.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/widgets/widget-filter.min.js
vendored
2
dist/js/widgets/widget-filter.min.js
vendored
File diff suppressed because one or more lines are too long
@ -2861,6 +2861,12 @@ ts.filter = {
|
||||
}
|
||||
}
|
||||
c.$table.find('thead').find('select.' + tscss.filter + '[data-column="' + column + '"]').append(options);
|
||||
txt = wo.filter_selectSource;
|
||||
fxn = $.isFunction(txt) ? true : ts.getColumnData( table, txt, column );
|
||||
if (fxn) {
|
||||
// updating so the extra options are appended
|
||||
ts.filter.buildSelect(c.table, column, '', true, $header.hasClass(wo.filter_onlyAvail));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3520,19 +3526,20 @@ ts.filter = {
|
||||
fxn = wo.filter_indexed.functions[ columnIndex ];
|
||||
$cell = c.$headerIndexed[columnIndex];
|
||||
hasSelect = $cell.hasClass('filter-select');
|
||||
filterMatched = null;
|
||||
if ( fxn || ( hasSelect && val ) ) {
|
||||
if (fxn === true || hasSelect) {
|
||||
// default selector uses exact match unless "filter-match" class is found
|
||||
result = ($cell.hasClass('filter-match')) ? data.iExact.search(data.iFilter) >= 0 : data.filter === data.exact;
|
||||
filterMatched = ($cell.hasClass('filter-match')) ? data.iExact.search(data.iFilter) >= 0 : data.filter === data.exact;
|
||||
} else if (typeof fxn === 'function') {
|
||||
// filter callback( exact cell content, parser normalized content, filter input value, column index, jQuery row object )
|
||||
result = fxn(data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
filterMatched = fxn(data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
} else if (typeof fxn[ffxn || data.filter] === 'function') {
|
||||
// selector option function
|
||||
result = fxn[ffxn || data.filter](data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
filterMatched = fxn[ffxn || data.filter](data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
}
|
||||
} else {
|
||||
filterMatched = null;
|
||||
}
|
||||
if (filterMatched === null) {
|
||||
// cycle through the different filters
|
||||
// filters return a boolean or null if nothing matches
|
||||
$.each(ts.filter.types, function(type, typeFunction) {
|
||||
@ -3551,6 +3558,8 @@ ts.filter = {
|
||||
data.exact = (data.iExact + data.childRowText).indexOf( ts.filter.parseFilter(c, data.iFilter, columnIndex, data.parsed[columnIndex]) );
|
||||
result = ( (!wo.filter_startsWith && data.exact >= 0) || (wo.filter_startsWith && data.exact === 0) );
|
||||
}
|
||||
} else {
|
||||
result = filterMatched;
|
||||
}
|
||||
showRow = (result) ? showRow : false;
|
||||
}
|
||||
|
@ -732,6 +732,12 @@ ts.filter = {
|
||||
}
|
||||
}
|
||||
c.$table.find('thead').find('select.' + tscss.filter + '[data-column="' + column + '"]').append(options);
|
||||
txt = wo.filter_selectSource;
|
||||
fxn = $.isFunction(txt) ? true : ts.getColumnData( table, txt, column );
|
||||
if (fxn) {
|
||||
// updating so the extra options are appended
|
||||
ts.filter.buildSelect(c.table, column, '', true, $header.hasClass(wo.filter_onlyAvail));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1391,19 +1397,20 @@ ts.filter = {
|
||||
fxn = wo.filter_indexed.functions[ columnIndex ];
|
||||
$cell = c.$headerIndexed[columnIndex];
|
||||
hasSelect = $cell.hasClass('filter-select');
|
||||
filterMatched = null;
|
||||
if ( fxn || ( hasSelect && val ) ) {
|
||||
if (fxn === true || hasSelect) {
|
||||
// default selector uses exact match unless "filter-match" class is found
|
||||
result = ($cell.hasClass('filter-match')) ? data.iExact.search(data.iFilter) >= 0 : data.filter === data.exact;
|
||||
filterMatched = ($cell.hasClass('filter-match')) ? data.iExact.search(data.iFilter) >= 0 : data.filter === data.exact;
|
||||
} else if (typeof fxn === 'function') {
|
||||
// filter callback( exact cell content, parser normalized content, filter input value, column index, jQuery row object )
|
||||
result = fxn(data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
filterMatched = fxn(data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
} else if (typeof fxn[ffxn || data.filter] === 'function') {
|
||||
// selector option function
|
||||
result = fxn[ffxn || data.filter](data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
filterMatched = fxn[ffxn || data.filter](data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
}
|
||||
} else {
|
||||
filterMatched = null;
|
||||
}
|
||||
if (filterMatched === null) {
|
||||
// cycle through the different filters
|
||||
// filters return a boolean or null if nothing matches
|
||||
$.each(ts.filter.types, function(type, typeFunction) {
|
||||
@ -1422,6 +1429,8 @@ ts.filter = {
|
||||
data.exact = (data.iExact + data.childRowText).indexOf( ts.filter.parseFilter(c, data.iFilter, columnIndex, data.parsed[columnIndex]) );
|
||||
result = ( (!wo.filter_startsWith && data.exact >= 0) || (wo.filter_startsWith && data.exact === 0) );
|
||||
}
|
||||
} else {
|
||||
result = filterMatched;
|
||||
}
|
||||
showRow = (result) ? showRow : false;
|
||||
}
|
||||
|
@ -359,6 +359,12 @@ ts.filter = {
|
||||
}
|
||||
}
|
||||
c.$table.find('thead').find('select.' + tscss.filter + '[data-column="' + column + '"]').append(options);
|
||||
txt = wo.filter_selectSource;
|
||||
fxn = $.isFunction(txt) ? true : ts.getColumnData( table, txt, column );
|
||||
if (fxn) {
|
||||
// updating so the extra options are appended
|
||||
ts.filter.buildSelect(c.table, column, '', true, $header.hasClass(wo.filter_onlyAvail));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1018,19 +1024,20 @@ ts.filter = {
|
||||
fxn = wo.filter_indexed.functions[ columnIndex ];
|
||||
$cell = c.$headerIndexed[columnIndex];
|
||||
hasSelect = $cell.hasClass('filter-select');
|
||||
filterMatched = null;
|
||||
if ( fxn || ( hasSelect && val ) ) {
|
||||
if (fxn === true || hasSelect) {
|
||||
// default selector uses exact match unless "filter-match" class is found
|
||||
result = ($cell.hasClass('filter-match')) ? data.iExact.search(data.iFilter) >= 0 : data.filter === data.exact;
|
||||
filterMatched = ($cell.hasClass('filter-match')) ? data.iExact.search(data.iFilter) >= 0 : data.filter === data.exact;
|
||||
} else if (typeof fxn === 'function') {
|
||||
// filter callback( exact cell content, parser normalized content, filter input value, column index, jQuery row object )
|
||||
result = fxn(data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
filterMatched = fxn(data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
} else if (typeof fxn[ffxn || data.filter] === 'function') {
|
||||
// selector option function
|
||||
result = fxn[ffxn || data.filter](data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
filterMatched = fxn[ffxn || data.filter](data.exact, data.cache, data.filter, columnIndex, $rows.eq(rowIndex), c);
|
||||
}
|
||||
} else {
|
||||
filterMatched = null;
|
||||
}
|
||||
if (filterMatched === null) {
|
||||
// cycle through the different filters
|
||||
// filters return a boolean or null if nothing matches
|
||||
$.each(ts.filter.types, function(type, typeFunction) {
|
||||
@ -1049,6 +1056,8 @@ ts.filter = {
|
||||
data.exact = (data.iExact + data.childRowText).indexOf( ts.filter.parseFilter(c, data.iFilter, columnIndex, data.parsed[columnIndex]) );
|
||||
result = ( (!wo.filter_startsWith && data.exact >= 0) || (wo.filter_startsWith && data.exact === 0) );
|
||||
}
|
||||
} else {
|
||||
result = filterMatched;
|
||||
}
|
||||
showRow = (result) ? showRow : false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user