InitComplete event to be able to display a message
InitComplete event to be able to display a message
klermann
Posts: 277Questions: 67Answers: 1
Hello Allan, I'm trying to use the initComplete event to be able to display a message for when the datatable is empty with no data, and when to contain any item (data) from an item the event delete the message. Only this event loads only once it does not come in when it is dynamically loaded to fire oTable.ajax.load (). How can I resolve this issue using the datatable events?
`"initComplete": function(settings, json) {
if(json.iTotalDisplayRecords == 0){
$(this).html('<div class="div-message">Message</div>');
}
if(json.iTotalDisplayRecords == 1){
$('div-message').hide();
oTable.ajax.load();
}
},`
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
initComplete
only runs once after the initial Datatable has been loaded.I would consider using the
xhr
to display the message if zero records are returned.Kevin
You have example? Ops Sorry!
I would suggest to look into
language.emptyTable
which you can use to customize the message when the table is empty.For example:
See more articles about jQuery DataTables on gyrocode.com.
Perfect gyrocode, thanks!