You can use the init.dt
event as follows:
$('#example').on('init.dt', function(e, settings, json){ console.log( 'Table initialisation complete: '+new Date().getTime() ); }); $('#example').dataTable();
From the manual:
init
event is raised when your table is fully initialized, loaded, and rendered, especially when using an ajax
data source.
NOTES
If you are going to hide / show the table, you will need to use the columns.adjust()
method to recalculate the width of the columns after the table becomes visible.
For instance:
$('#example-container').hide(); $('#example').on('init.dt', function(e, settings, json){ $('#example-container').show(); $(this).DataTable().columns.adjust(); }); $('#example').dataTable();
source share