You can use the fnDrawCallback function. It gets called every time the table is drawn. This would include when the table is loaded with data, sorted or filtered.
You better use fnInitComplete:
$(document).ready(function () {
$('#example').dataTable({
"fnInitComplete": function (oSettings, json) {
alert('DataTables has finished its initialisation.');
}
});
})







![SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes](https://blog.rahulbhutani.com/wp-content/uploads/2020/04/123-100x70.jpg)










