22

I am using the DataTables plugin (www.datatables.net) for jQuery to display tables on a web page.

After reading through the documentation and doing some searches, I am unable to find out how to completely suppress or hide table headers, using the DataTables options or API.

5 Answers 5

37

Why don't you simply hide them through css (i think datatables requires a thead section to work)?

.dataTables_wrapper table thead{
    display:none;
}

fiddle here: http://jsfiddle.net/LhZF3/

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

2 Comments

Thank you. Messing with the DOM/CSS is not the most elegant solution, but at least it works :-)
Works great, but still it is very weird that the API itself won't expose such functionality.
15

I know the question is pretty old, but I searched for it today and found another solution ...

In your js / coffee file:

$("#selector").dataTable({
  ... your other options ...

  fnDrawCallback: -> $("#selector thead").remove()
})

Pure JS variant:

$("#selector").dataTable({
  ... your other options ...

  fnDrawCallback: function() {
    $("#selector thead").remove();
  }
});

2 Comments

this worked for me - with display:none the table header still influences the body rendering ..
7

Simple add the style display:none inline style to your thead tag.

    <thead style="display:none;">
    </thead>

Comments

1

Just add this to your css:

thead {
  display:none;
}

1 Comment

Careful. This will suppress all headers from all tables, regardless of Datatables or not.
0

The other answers work, but if you are using the KeyTable extension with the DataTables Editor, hiding the header (via display:none) or removing it (via $().remove()) will prevent KeyTable from working properly. (I'm not sure why, but this is empirically true for me with DataTables v.1.13.5, Editor v.2.0.8, and KeyTable v2.10.0: inline editing is no longer triggered by mouse clicks or key presses when the header is removed/hidden.)

A workaround that doesn't have this drawback is to set the header row height to 0, using CSS:

#selector thead tr {
  height: 0;
}

or the drawCallback configuration setting:

drawCallback: function (settings) {
  $("#selector thead tr").css('height', 0);
}

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.