Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35271

Filtering - Different types of filtering on individual columns

$
0
0

Hi, 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 dropdown 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.

```js

$("#example tfoot td.st-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>');
        } );      
} );

`

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


Viewing all articles
Browse latest Browse all 35271

Trending Articles