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();
For hiding, I used the below code: var oTable = $('#example'). dataTable(); // 'example is the table id' oTable. hide();
To hide and show columns use columns() and visible() method. Call it on dataTables instance and pass column index in columns() method and false to visible() method. Similarly, pass true to visible() if you want to show the columns.
DataTables and show and hide columns dynamically through use of this option and the column(). visible() / columns(). visible() methods. This option can be used to get the initial visibility state of the column, with the API methods used to alter that state at a later time.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With