Multifilter with text input does not work anymore

Multifilter with text input does not work anymore

NdinhNdinh Posts: 4Questions: 2Answers: 0

Official Link: https://datatables.net/examples/api/multi_filter.html

Nothing happens if you enter a text. Tested with Chrome, Firefox and Edge.

Replies

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi Ndinh,

    Thanks for pointing that out, we have filed it as a bug and will have it fixed as soon as possible (A minute or two). The fix is really easy simply remove the clear from the event listener so that the code looks like so...

    $(document).ready(function() {
        // Setup - add a text input to each footer cell
        $('#example tfoot th').each( function () {
            var title = $(this).text();
            $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
        } );
     
        // DataTable
        var table = $('#example').DataTable();
     
        // Apply the search
        table.columns().every( function () {
            var that = this;
     
            $( 'input', this.footer() ).on( 'keyup change', function () {
                if ( that.search() !== this.value ) {
                    that
                        .search( this.value )
                        .draw();
                }
            } );
        } );
    } );
    

    Hope this helps,

    Sandy

This discussion has been closed.