Filter widget: start filter values are now preserved. Fixes #452

This commit is contained in:
Mottie 2013-12-20 18:35:19 -06:00
parent d0c135165e
commit 192eeaa1ef

View File

@ -634,22 +634,17 @@ ts.filter = {
c.$table.trigger('filterInit'); c.$table.trigger('filterInit');
}, },
setDefaults: function(table, c, wo) { setDefaults: function(table, c, wo) {
var indx, isArray, var indx, isArray, saved,
filters = [], // get current (default) filters
filters = ts.getFilters(table),
columns = c.columns; columns = c.columns;
if (wo.filter_saveFilters && ts.storage) { if (wo.filter_saveFilters && ts.storage) {
filters = ts.storage( table, 'tablesorter-filters' ) || []; saved = ts.storage( table, 'tablesorter-filters' ) || [];
isArray = $.isArray(filters); isArray = $.isArray(saved);
// make sure we're not just saving an empty array // make sure we're not just getting an empty array
if (isArray && filters.join('') === '' || !isArray ) { filters = []; } if ( !(isArray && saved.join('') === '' || !isArray) ) { filters = saved; }
} }
// if not filters saved, then check default settings c.$table.data('lastSearch', filters);
if (!filters.length) {
for (indx = 0; indx < columns; indx++) {
filters[indx] = c.$headers.filter('[data-column="' + indx + '"]:last').attr(wo.filter_defaultAttrib) || filters[indx];
}
}
$(table).data('lastSearch', filters);
return filters; return filters;
}, },
buildRow: function(table, c, wo) { buildRow: function(table, c, wo) {