jQuery DataTable : Individual column searching on table header

后端 未结 6 645
执念已碎
执念已碎 2020-12-06 06:09

I have followed the steps on Individual column searching (text inputs) and Individual column searching (select inputs) to use multiple filters on jQuery DataTable and there

6条回答
  •  伪装坚强ぢ
    2020-12-06 07:03

    // Setup - add a text input to each footer cell
    $('#example thead th').each( function () {
        var title = $(this).text();
        $(this).html( '' );
    } );
    
    // DataTable
    var table = $('#example').DataTable();
    
    // Apply the search
    table.columns().every( function () {
        var that = this;
    
        $( 'input', this.header() ).on( 'keyup change clear', function () {
            if ( that.search() !== this.value ) {
                that
                    .search( this.value )
                    .draw();
            }
        } );
    } );

提交回复
热议问题