JavaScript runtime error: Unable to get property 'className' of undefined or null reference

JavaScript runtime error: Unable to get property 'className' of undefined or null reference

joellerjoeller Posts: 48Questions: 9Answers: 0

I created a data table on an HTML table with the following code.
$('#ContractsView').dataTable({
"aaSorting": []
});

This runs fine when the table is empty

When this code runs for a table which has rows I get this error:

Unhandled exception at line 669, column 8 in https://localhost:44308/Scripts/jquery.dataTables.js

0x800a138f - JavaScript runtime error: Unable to get property 'className' of undefined or null reference

At this code
/* Classes */
if ( bClass )
{
nCell.className += ' '+oCol.sClass;
}

I have two other html tables which are entered the same way before hand.

$(document).ready(function () {
$('#FundDocsView').dataTable({
"aaSorting" : []
});
$('#PRView').dataTable({
"aaSorting": []
});
$('#ContractsView').dataTable({
"aaSorting": []
});
});

They run with no problem. The ContractsView tables runs fine when there is no data,
but as soon as the table is populated this error occurs
I am confused what would cause this error.

This question has an accepted answers - jump to answer

Answers

  • joellerjoeller Posts: 48Questions: 9Answers: 0

    I tried to make a js fiddler location but I could not figure out how to included multiple folders to place the all of the css files and the script files.

    I tried to include the html for the page here but the comment field rejected it as too long.

    I'd put it in a file and attach that, but I see no way of doing that.

    I have no idea how to deploy this in a fashion that would provide access to the people on this site.

    If anyone things they can resolve this with the HTML of the page, I would be happy to send it to them.

    Please advise.

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    Answer ✓

    I think the most common error that leads to this is the number of columns in thead not being equal to the number in tbody.

    To create a test case you can use the DataTables live site which includes DataTables in the default page.

    Allan

  • joellerjoeller Posts: 48Questions: 9Answers: 0

    Good job alian that fixed it. HUZZA!!!

  • joellerjoeller Posts: 48Questions: 9Answers: 0

    I tried using the Data Tables Live site but I could not figure out how to make it work. particularly since I needed to add other libraries such as the JQuery UI data trees and its styles.

This discussion has been closed.