I really do love the awesome DataTable plugin which creates useful dynamic, with oodles of extra functionality, tables out of plain old vanilla HTML tables. Today’s quick tip however looks at how one destroys an already instantiated DataTable instance, say because you want to recreate it at a later stage in a completely different format but want to reuse the selector currently bound to the existing table.
Enter the useful bDestroy option which you can add to your constructor. Given this option set to true, DataTables with first brutally murder any existing elements attached to the selected selector before recreating the desired DataTable. If no existing table is found attached to the given selector, then the DataTable is created as it normally would.
An example:
$(document).ready(function() {
$('#example').dataTable( {
...
} );
/* Some time later.... */
$('#example').dataTable( {
...
"bDestroy": true
} );
} );
Simple and very useful. In other words, nifty.
Related Link: http://www.datatables.net/usage/options