mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Filter: External filters can set initial values. Fixes #831
An empty string is better than an undefined filter
This commit is contained in:
parent
71f55cec70
commit
d3170096b2
12
dist/js/jquery.tablesorter.widgets.js
vendored
12
dist/js/jquery.tablesorter.widgets.js
vendored
@ -1,4 +1,4 @@
|
||||
/*! tablesorter (FORK) widgets - updated 02-25-2015 (v2.20.1)*/
|
||||
/*! tablesorter (FORK) widgets - updated 02-26-2015 (v2.20.1)*/
|
||||
/* Includes: storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort */
|
||||
/*! Widget: storage */
|
||||
;(function ($, window, document) {
|
||||
@ -801,7 +801,7 @@ ts.filter = {
|
||||
},
|
||||
|
||||
setDefaults: function(table, c, wo) {
|
||||
var isArray, saved, indx,
|
||||
var isArray, saved, indx, col, $filters,
|
||||
// get current (default) filters
|
||||
filters = ts.getFilters(table) || [];
|
||||
if (wo.filter_saveFilters && ts.storage) {
|
||||
@ -812,8 +812,12 @@ ts.filter = {
|
||||
}
|
||||
// if no filters saved, then check default settings
|
||||
if (filters.join('') === '') {
|
||||
for (indx = 0; indx < c.columns; indx++) {
|
||||
filters[indx] = c.$headers.filter('[data-column="' + indx + '"]:last').attr(wo.filter_defaultAttrib) || filters[indx];
|
||||
// allow adding default setting to external filters
|
||||
$filters = c.$headers.add( wo.filter_$externalFilters ).filter('[' + wo.filter_defaultAttrib + ']');
|
||||
for (indx = 0; indx <= c.columns; indx++) {
|
||||
// include data-column="all" external filters
|
||||
col = indx === c.columns ? 'all' : indx;
|
||||
filters[indx] = $filters.filter('[data-column="' + col + '"]').attr(wo.filter_defaultAttrib) || filters[indx] || '';
|
||||
}
|
||||
}
|
||||
c.$table.data('lastSearch', filters);
|
||||
|
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
@ -4,7 +4,7 @@
|
||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
||||
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
||||
*/
|
||||
/*! tablesorter (FORK) widgets - updated 02-25-2015 (v2.20.1)*/
|
||||
/*! tablesorter (FORK) widgets - updated 02-26-2015 (v2.20.1)*/
|
||||
/* Includes: storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort */
|
||||
/*! Widget: storage */
|
||||
;(function ($, window, document) {
|
||||
@ -807,7 +807,7 @@ ts.filter = {
|
||||
},
|
||||
|
||||
setDefaults: function(table, c, wo) {
|
||||
var isArray, saved, indx,
|
||||
var isArray, saved, indx, col, $filters,
|
||||
// get current (default) filters
|
||||
filters = ts.getFilters(table) || [];
|
||||
if (wo.filter_saveFilters && ts.storage) {
|
||||
@ -818,8 +818,12 @@ ts.filter = {
|
||||
}
|
||||
// if no filters saved, then check default settings
|
||||
if (filters.join('') === '') {
|
||||
for (indx = 0; indx < c.columns; indx++) {
|
||||
filters[indx] = c.$headers.filter('[data-column="' + indx + '"]:last').attr(wo.filter_defaultAttrib) || filters[indx];
|
||||
// allow adding default setting to external filters
|
||||
$filters = c.$headers.add( wo.filter_$externalFilters ).filter('[' + wo.filter_defaultAttrib + ']');
|
||||
for (indx = 0; indx <= c.columns; indx++) {
|
||||
// include data-column="all" external filters
|
||||
col = indx === c.columns ? 'all' : indx;
|
||||
filters[indx] = $filters.filter('[data-column="' + col + '"]').attr(wo.filter_defaultAttrib) || filters[indx] || '';
|
||||
}
|
||||
}
|
||||
c.$table.data('lastSearch', filters);
|
||||
|
@ -458,7 +458,7 @@ ts.filter = {
|
||||
},
|
||||
|
||||
setDefaults: function(table, c, wo) {
|
||||
var isArray, saved, indx,
|
||||
var isArray, saved, indx, col, $filters,
|
||||
// get current (default) filters
|
||||
filters = ts.getFilters(table) || [];
|
||||
if (wo.filter_saveFilters && ts.storage) {
|
||||
@ -469,8 +469,12 @@ ts.filter = {
|
||||
}
|
||||
// if no filters saved, then check default settings
|
||||
if (filters.join('') === '') {
|
||||
for (indx = 0; indx < c.columns; indx++) {
|
||||
filters[indx] = c.$headers.filter('[data-column="' + indx + '"]:last').attr(wo.filter_defaultAttrib) || filters[indx];
|
||||
// allow adding default setting to external filters
|
||||
$filters = c.$headers.add( wo.filter_$externalFilters ).filter('[' + wo.filter_defaultAttrib + ']');
|
||||
for (indx = 0; indx <= c.columns; indx++) {
|
||||
// include data-column="all" external filters
|
||||
col = indx === c.columns ? 'all' : indx;
|
||||
filters[indx] = $filters.filter('[data-column="' + col + '"]').attr(wo.filter_defaultAttrib) || filters[indx] || '';
|
||||
}
|
||||
}
|
||||
c.$table.data('lastSearch', filters);
|
||||
|
Loading…
Reference in New Issue
Block a user