Search code examples
jqueryfiltertablesorter

Tablesorter Filter with multiple "values" in cell


I'm using tablesorter with Filter widget but i have a problem with the filter.

I'm using filter-select class in the header and it's working fine.

Problem is i have the cells in which there can be more than 1 data, but filter is getting the text all togheter instead of each value separate.

Just to be clear:

<tr>
    <td>John Wayne</td>
    <td>
            <div class="rip">Riplet</div>
            <div class="rip">Pipe</div>
    </td>
<tr>

The fitler select appears with 1 option like this "RipletPipe", but i need it to be 2 options "Riplet" and "Pipe".

I've tried with functions etc but I don't seem to get to it.

Main problem is I think that the data in the "multiple value cell" is dynamic.

Please help me :)


Solution

  • Using Motties help I achieved what I needed.

    I'm posting my solution for future use for users needing something similar.

    filter_selectSource: function (table, column, onlyAvail) {
            var arry = [];
    
                tds = $(table).find('tbody tr').find('td:eq('+column+')');
    
                tds.find('.rip').each(function(i,n){
                    arry.push($(this).text());
                });
    
            return $.map(arry, function(n){ return n; });
     }
    

    I guess this code can be optimized but for now it works and it's ok for me.

    To make sure filtering works you need to add filter-match to the header else it will search for exact value and it won't find the rows.