individual column filtering

individual column filtering

jedyjedy Posts: 1Questions: 1Answers: 0
edited April 2021 in DataTables

Hi, i used this code to individual column filtering but how to disable/hidden first column if i dont want to?

$(document).ready(function() {
    $('#example thead tr').clone(true).appendTo( '#example thead' );
    $('#example thead tr:eq(1) th').each( function (i) {
        var title = $(this).text();
        $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
 
        $( 'input', this ).on( 'keyup change', function () {
            if ( table.column(i).search() !== this.value ) {
                table
                    .column(i)
                    .search( this.value )
                    .draw();
            }
        } );
    } );

    var table = $('#example').DataTable( {
        orderCellsTop: true,
        fixedHeader: true
    } );
} );

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583
    Answer ✓
    $('#example thead tr:eq(1) th').each( function (i) {
    

    This will do all the headers, so you need to restrict the theads you want to put the input elements onto, or just specifically state the ones you do.

    Colin

This discussion has been closed.