Reputation: 7877
How do I to hide jQuery datatables, when I want to toggle the datatable's visibility? The problem is if I write hide statement it only hides the rows, not the headers and footer. How can I hide datatable fully?
For hiding, I used the below code:
var oTable = $('#example').dataTable(); // 'example is the table id'
oTable.hide();
Upvotes: 12
Views: 30072
Reputation: 4344
For me (and I know this is a wierd need) I needed to hide the main table but keep the results (i.e. X results of X filtered).
$('div.dataTables_wrapper thead,div.dataTables_wrapper tbody').hide();
The above fixed it for me. If you have a footer you would need to add ,div.dataTables_wrapper tfoot
as well.
Upvotes: 0
Reputation: 1063
i think the best way is to include the table inside a div and hide the div
<div id='divTable'>
<table>
</table>
</div>
$('#divTable').hide();
Upvotes: 16
Reputation: 8346
Try this
$('#example').parents('div.dataTables_wrapper').first().hide();
Upvotes: 24