12

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();
1
  • @Rob : Yes it also gives same result Commented Apr 5, 2013 at 7:10

3 Answers 3

24

Try this

$('#example').parents('div.dataTables_wrapper').first().hide();
Sign up to request clarification or add additional context in comments.

Comments

16

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();

Comments

0

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.

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.