javascript - How to filter jQuery Tablesorter by multiple columns using OR logic -
i looking means of doing or filter against multiple columns in jquery tablesorter datatable multiple column or filter. upgraded 2.21.5.
i have fiddle example. have tried filter_functions:
filter_functions: { '.filter-or': function (e, n, f, i, $r, c) { /* manually check row columns class of filter-or */ } }
but applying function classes overrides filter-availonly option.
not sure how move forward this.
if understanding request, maybe try (demo):
$(function () { var $table = $('table'), // 'filter-or' column indexes orcolumns = $('.filter-or').map(function (i) { return this.cellindex; }).get(), filterfxn = function (e, n, f, i, $r, c) { var col, v, showrow = false, content = []; $r.children().filter(function (indx) { if (orcolumns.indexof(indx) > -1) { v = (c.$filters.eq(indx).find('.tablesorter-filter').val() || '').tolowercase(); showrow = showrow || $(this).text().tolowercase() === v; } }); return showrow; }; $table.tablesorter({ theme: 'green', widgets: ['uitheme', 'zebra', 'columns', 'filter'], sortreset: true, sortrestart: true, widthfixed: true, widgetoptions: { filter_functions: { '.filter-or': { 'yes': filterfxn, 'no' : filterfxn } } } }); });
Comments
Post a Comment