Rajaram Shelar
Rajaram Shelar

Reputation: 7877

How to hide jQuery datatables

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

Answers (3)

Antony
Antony

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

badr slaoui
badr slaoui

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

msapkal
msapkal

Reputation: 8346

Try this

$('#example').parents('div.dataTables_wrapper').first().hide();

Upvotes: 24

Related Questions