Search code examples
jquerytablesorter

Tablesorter - filter functions on empty cells


I'm using the tablesorter 2.7.9 (Mottie's fork) with the filter functions widget and I'd like to have the built-in select droplist be able to select empty cell values as a filter option. Does anyone know an easy way to do this aside from putting fake values in all the empty cells? Already my filter droplist contains 2 blank options: one for deselecting the filter and one to match the data value from my table, but of course setting it to this just deselects the filter.


Solution

  • Sadly there isn't an easy way to select empty cells with the way the filter widget is written. The main problem is how do we differentiate between clearing the filter and searching for empty table cells?

    I could add some way to specifically find empty table cells, or as you said add "fake" values into the empty table cells - one way is to add <span style="display:none">{empty}</span> inside of empty cells. Then the select dropdown would include an {empty} entry so users know what they are selecting (demo).

    Would that work for you?