Remove first column filter

Remove first column filter

jagswebjagsweb Posts: 26Questions: 6Answers: 0

I am using datatables with multicolumn filtering and child rows. I need to remove the column search from the first column as there is no data in this column. This is the control column for the child rows so there are only images in this column.

I figure that i need to make a change in one of the following two JS snippets

   var table = $('#example').DataTable( {
    "ajax": "../data/cat-data.txt",
    "columns": [
        {
            "class":          'details-control',
            "orderable":      false,
            "data":           null,
            "defaultContent": ''
        },
        { "data": "Year" },
        { "data": "Make" },
        { "data": "Model" },
        { "data": "Engine" },
        { "data": "PartNumber" }
    ],
    "order": [[1,'asc'], [2,'asc'], [3,'asc'], [4,'asc'], [5,'asc']],
    "bSort": false,
    "bPaginate": true,
    "bLengthChange": true,
    "bInfo": false,
    "bAutoWidth": true,
    "iCookieDuration": 60*60*24, // 1 day 
} );

OR

    $('#example thead th').each( function () {
    var title = $('#example thead th').eq( $(this).index() ).text();
    $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );

Can someone please help me so i can get this search removed from the first column. Thanks for any assistance. Datatables ROCKS!

Answers

  • jagswebjagsweb Posts: 26Questions: 6Answers: 0
    edited May 2014

    I got some help from someone and below is the edited code from above

    $('#example thead th').each( function () { var title = $('#example thead th').eq( 
    $(this).index() ).text(); if($(this).index() !=0) $(this).html( '<input type="text"
    placeholder="Search '+title+'" />' ); } );
    
This discussion has been closed.