preset filter searches work again. Fixes #511 & #525

This commit is contained in:
Mottie 2014-03-03 20:24:02 -06:00
parent 7269aadc74
commit 0107e93c94

View File

@ -654,15 +654,21 @@ ts.filter = {
c.$table.trigger('filterInit'); c.$table.trigger('filterInit');
}, },
setDefaults: function(table, c, wo) { setDefaults: function(table, c, wo) {
var isArray, saved, var isArray, saved, indx,
// get current (default) filters // get current (default) filters
filters = ts.getFilters(table); filters = ts.getFilters(table) || [];
if (wo.filter_saveFilters && ts.storage) { if (wo.filter_saveFilters && ts.storage) {
saved = ts.storage( table, 'tablesorter-filters' ) || []; saved = ts.storage( table, 'tablesorter-filters' ) || [];
isArray = $.isArray(saved); isArray = $.isArray(saved);
// make sure we're not just getting an empty array // make sure we're not just getting an empty array
if ( !(isArray && saved.join('') === '' || !isArray) ) { filters = saved; } if ( !(isArray && saved.join('') === '' || !isArray) ) { filters = saved; }
} }
// 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];
}
}
c.$table.data('lastSearch', filters); c.$table.data('lastSearch', filters);
return filters; return filters;
}, },