console log error for zero config

console log error for zero config

jeffbrownjeffbrown Posts: 4Questions: 1Answers: 0

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

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    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

  • jeffbrownjeffbrown Posts: 4Questions: 1Answers: 0

    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.

  • jeffbrownjeffbrown Posts: 4Questions: 1Answers: 0

    Well, a step forward, adding in the empty th got me passed the first hurdle, but then I got

    TypeError: 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 instead

  • jeffbrownjeffbrown Posts: 4Questions: 1Answers: 0

    Excellent, that solved the issue, the rest will be some css clean up ... thanks.

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    FYI - See this example regarding rowspan and colspan in the header. Also they are not supported in the tbody as exaplained here.

    Kevin

This discussion has been closed.