console log error for zero config
console log error for zero config

Apologies if I'm asking this question in the wrong forum or something.
Link to test case:
I'm a contractor working on a site that is not public so I can't show the link of this happening for a few reasons.
Debugger code (debug.datatables.net):
https://debug.datatables.net/idapom -- I'm not sure how to make this public
Error messages shown:
in the console log:
TypeError: c is undefined jquery.dataTables.min.js:104:245
Description of problem:
Using the up-to-date
Using the zero configuration setup on a table, the call to .DataTable() is the point throwing the error.
The code on the site works like this:
A javascript object pulls data from an api,
The javascript creates the DOM table elements then attaches them to the <tbody> of the table.
For my code I have a variable pointing at the table
itself in the DOM ($table)
And another pointing at the tbody
element of the above table $tbody;
// Add the output buffer to the tbody.
//
$tbody.append(this.output);
// Initialize the data table -- zero config
//
$table
.filter(':not(.dataTabled)')
.addClass('dataTabled');
.DataTable()
;
Is there any idea of what I am doing wrong? Or is this a known problem?
This question has an accepted answers - jump to answer
Answers
You normally get that error when the number of columns in the header, body or JSON don't match. Thanks for the debug, that's showing 0 columns in the table - so probably related.
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Ah ok, thanks. That makes some sort of sense, 2 columns in the table, 1 is text the other is an action button. But the title header and some of the rows have colspan="2" ...
I'll try by adding a new table header
th
that is just empty ... will report back.Well, a step forward, adding in the empty
th
got me passed the first hurdle, but then I gotTypeError: n is undefined jquery.dataTables.min.js:37:476
I'm assuming that this is due to the colspan="2" in some of the rows ... I will throw in some empty
td
for those rows insteadExcellent, that solved the issue, the rest will be some css clean up ... thanks.
FYI - See this example regarding rowspan and colspan in the header. Also they are not supported in the
tbody
as exaplained here.Kevin