DataTables : filtering different types of filterin

2019-08-02 14:25发布

问题:

I am using DataTables to display and filter data in my .jsp page and it works great. I have a table with 6 columns and each is set-up with a drop-down list to filter the tables content.

This is nice , but one of the columns is a 'Description' column and it would be nice to filter based on text input , for that individual column.

Is it possible to have multiple filter types on a table? Below is the code I use currently.

I've tried searching for an example of this but with no success. Any advice will be greatly appreciated!

$("#example tfoot td.ex-filter").each( function ( i ) {
var select = $('<select><option value=""></option></select>')
    .appendTo( $(this).empty() )
    .on( 'change', function () {
        var val = $(this).val();

        table.column( i )
            .search( val ? '^'+$(this).val()+'$' : val, true, false )
            .draw();
    } );

    table.column( i ).data().unique().sort().each( function ( d, j ) {
        select.append( '<option value="' + d  + '">' + d + '</option>');
    } );     
} );