ComputerLocus ComputerLocus - 7 days ago 6
Javascript Question

Datatables: Uncaught TypeError: Cannot read property 'parentNode' of undefined

I'm getting two errors in my console upon viewing a webpage. Datatables is being used, and I am quite sure (as the errors state) that the issue is related to Datatables. The problem here is that I did not write this code, I am merely now trying to fix issues in the code. The odd thing is that this section of the code should have been working before, as I can visibly see it working on the live version. Am I correct in what I believe to be the error? If so, what is the best way to go about debugging this, when the code is not made by me, and the code and data is in large quantities?


DataTables warning: Unexpected number of TD elements. Expected 2040
and got 1981. DataTables does not support rowspan / colspan in the
table body, and there must be one cell for each row/column
combination. jquery.dataTables.js:5840

Uncaught TypeError: Cannot read property 'parentNode' of undefined. jquery.dataTables.js:2843

Answer

Do you have a URL that you can post so that we can take a look?

Cannot read propertyparentNodeof undefined is a javascript error that happens because you are trying to get the parentNode of something that doesn't exist.

The other error seems quite obvious? The number of TD elements in a TR is not in line with the rest of the table. Look at the HTML and check if the number of TD & TH elements in the THEAD, TFOOT and TBODY are all the same count. "DataTables does not support rowspan / colspan in the table body"

Please post a URL or HTML/JS snippet of the table, preferrably on http://www.jsfiddle.net