get a table with a message "emptyTable", if the aaData is an empty array
get a table with a message "emptyTable", if the aaData is an empty array
I am doing a ajax request to the server to get the data.When the array is empty, I want it to be displayed in a table row "emptyTable". I get message "emptyTable", if not used aoColumnDefs, but I'm getting warning "Requested unknown parameter ... " . I do not want to receive a warning!
var searchTable = $('#baseTasks').dataTable({
bFilter: false, bInfo: false, "bLengthChange": false,
scrollY:"600px",scrollCollapse: true, paging:false,
"aaData": tasks,
"aoColumns": [
{ "mData": "name"
},{"mData": "schoolClass"
},{"mData": "complexity"
},{"mData": "author"
}]
});
if I use aoColumnDefs, I do not get warning, but I get an empty table without message "emptyTable".
"aoColumnDefs": [
{
"mData": null,
"sDefaultContent": null,
"aTargets": [ -1 ]
}],
How do I get a table with a message "emptyTable", if the aaData is an empty array?
This question has an accepted answers - jump to answer
Answers
That error suggests that aaData is not empty. Perhaps it has an inner empty array that should be removed? Can you link to the page showing the issue please.
Allan
Thank you for your answer, Allan, I can not give a link to the page, as the development is local. But I could recreate example here http://jsfiddle.net/bbubdp37/. By clicking on the "archive", there is bug described by me.
I see - thanks for the test case. Why are you attempting to add a row to an empty table, when you want an empty table? :-)
Just use fnClearTable and then don't add anything: http://jsfiddle.net/bbubdp37/1/
Allan
I attempting to add a row to an empty table for an example. Since when clicked, in reality, a ajax request is made, and the data array may be empty or not empty. And I simply add the response data in the table.
Thanks for your reply, now I will add a check if the data is empty, do not add anything to the table.
Too bad it does not come to mind immediately. :-)