Mottie / tablesorter

Github fork of Christian Bach's tablesorter plugin + awesomeness ~
https://mottie.github.io/tablesorter/docs/
2.61k stars 754 forks source link

Filter_formatter datepicker blocking default external sort #1600

Open MineralWizardOfOz opened 5 years ago

MineralWizardOfOz commented 5 years ago

Hi there, I have a tablesorter with the following initialization:

pagerOptions = {
    container: $(".pager"),
    output: '{page}/{filteredPages}',
    removeRows: false,
    size: 20,
    pageReset: false,
    fixedHeight:true
  };
  $('.tablesorter').tablesorter({
    dateFormat: 'us',
    widthFixed: true,
    fixedHeight: true,
    sortList: [[6,1]],
    headers: {
      0: {sorter:'digit'},
      4: {sorter: 'text'},
      7: {sorter: 'digit'},
      9: {sorter: 'false'}
    },
    widgets: ['zebra', 'filter'],
    widgetOptions : {
      filter_external : '.search',
      filter_reset: '.reset',
      filter_hideFilters: true,
      filter_formatter: {
        6 : function($cell, indx){
          return $.tablesorter.filterFormatter.uiDatepicker($cell, indx, {
            textFrom: 'From',
            textTo: 'To',
            changeMonth : true,
            changeYear : true
          });
        }
      }
    }
  }).tablesorterPager(pagerOptions);

Everything works fine, and it generates a table with two Datepickers that help sort checks from beginning date to end date. However, there is also an external search field on this same table that needs to search all of the columns as if they were strings. Since I already have the filter_formatter, the date column gets ignored by this search field (i.e. if there is a row whose date is "09/08/2018" and I type "09/" into the search field, it will not find it. I want the date range selector to filter the rows, and the search to also filter the rows as if they were strings. If I use the date range selector, it will). I have tried many different option combinations, but nothing quite achieves what I am looking for. Is there any way to allow both of these to work at the same time?

Thanks!

Mottie commented 5 years ago

Hi @MineralWizardOfOz!

Hmm, yeah the external search is only looking at the parsed data because of the filter_formatter... there isn't anything in place to work around this problem, but let me look at this problem more in depth when I get some free time this weekend.

Edit: Demo showing the issue - https://jsfiddle.net/Mottie/v5cmd1wx/ - enter 08 in the external input.

MineralWizardOfOz commented 5 years ago

Hey Mottie!

Did you ever get around to finding a solution to this filtering issue? I workshopped it a bit, but can't seem to find a combination of options that works for what I'm attempting to do. I might have to manually re-query upon search.