Disabling "Incorrect column count" warning for empty tables
Disabling "Incorrect column count" warning for empty tables
It's a common ocurrence that when populating a datatable, there will be no matching records. In this case, no rows are shown, and that's fine, the "No data available in table" message is shown. However, since there are no rows in HTML, the "Incorrect column count" JS warning is also triggered. Is there a way to disable it? Can't really use DataTables with this message popping up each time there is an empty table.
Of course I could always generate empty rows and show the No data message manually for theses cases, but seems like too much work when a simple flag to disable the warning should do the trick.
Replies
That error doesn't occur with this HTML sourced table, which sounds like what you have, with no rows:
https://live.datatables.net/tezexupo/1/edit
If this doesn't help please provide or update my test case to show the issue you are having.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I am experiencing the exact same issue using:
https://cdn.datatables.net/1.13.5/js/jquery.dataTables.min.js or https://nightly.datatables.net/js/jquery.dataTables.js
Can you link to a page showing the issue please? Kevin linked to an example showing DataTables behaving as expected. We'd need a link to a page showing the issue so we can debug it.
Allan
You have to totally remove
<tbody></tbody>
then it will not prompt the correct column count..Previously, I was using
also having this error prompting. But I remove the
<tbody>
then problem solved.With an empty tbody, I'm not seeing the error: https://live.datatables.net/tezexupo/5/edit ?
Allan
The error was probably due to the
<td colspan="4">No Data</td>
you have in thetbody
. Datatables doesn't support colspan or rowspan in thetbody
. See the HTML docs for details.Kevin
Gah - I missed another obvious one! Thanks Kevin