0

I want to hide the input fields for filtering Job and Age, like in the picture.

How can do that please I need help for my problem.

this my example http://live.datatables.net/piqidoqo/610/edit

enter image description here

5
  • Do you want to hide them, or remove them? Commented Oct 31, 2018 at 7:25
  • Use table.columns([1,2]).visible(false) ... Commented Oct 31, 2018 at 7:36
  • @Steven I want to hide the input field for search 1,2 only and keep the data for job and age. Commented Oct 31, 2018 at 8:53
  • @davidkonrad thank you for help, but I want to hide the input field for search 1,2 only and keep the data for job and age. Commented Oct 31, 2018 at 8:53
  • Problem solved live.datatables.net/yaxusisi/1/edit Commented Oct 31, 2018 at 21:08

2 Answers 2

0

You can use the following

<td style="display:none">your html here</td>

along with

$('#your_table').DataTable( {
        "columnDefs": [
            {
                "targets": [ column_number_you_want_to_hide ],
                "visible": false,
            },
          ]
});

Know that column numbers start from 0 and not 1.

Sign up to request clarification or add additional context in comments.

1 Comment

Think you that help but, I want to hide the input field for search 1,2 only and keep the data for job and age.
0

Problem solved with this code http://live.datatables.net/yaxusisi/1/edit

$(document).ready(function() {

   // Create the DataTable
   var table = $("#example").DataTable({
     orderCellsTop: true,
    initComplete: function() {
    var table = this.api();

  // Add filtering
  table.columns([1,2]).every(function() {
    var that = this;

    // Create the `select` element
    var input = $('<input type="text" />')
      .appendTo($("thead tr:eq(1) td").eq(this.index()))
      .on("keyup", function() {
        that.search('^' + $(this).val() + '$', true, false).draw();
      });        
  });

  displaySearch();

}
 });
  });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.