tablesorter icon indicating copy to clipboard operation
tablesorter copied to clipboard

filter_startsWith in one column only

Open XanXus96 opened this issue 4 years ago • 1 comments

i want only the column 3 to be filtered with startsWith, i made a filter_function but the or operator is not working anymore

widgetOptions: {
        filter_searchDelay: 0,
        filter_columnFilters: true,
        //filter_startsWith: true,
        filter_functions: {
          3: function (e, n, f, i, $r, c, data) {
            let res = false;
            f.split("|").forEach((ff) => {
              if (e.startsWith(ff))
                res = true;
            });
            return res;
          },
        },
      },

XanXus96 avatar Dec 09 '21 16:12 XanXus96

Try this:

filter_functions: {
  3: function (e, n, f, i, $r, c, data) {
    return f.split("|").some(ff => e.startsWith(ff));
  },
},

Mottie avatar Dec 09 '21 22:12 Mottie