Uncaught TypeError: Cannot read properties of null (reading 'length')

Uncaught TypeError: Cannot read properties of null (reading 'length')

jbnvjbnv Posts: 9Questions: 4Answers: 1

This is the stack trace for the error:

jquery.dataTables.js:5934 Uncaught TypeError: Cannot read properties of null (reading 'length')
    at add (jquery.dataTables.js:5934:12)
    at _fnSortFlatten (jquery.dataTables.js:5954:3)
    at _fnSortingClasses (jquery.dataTables.js:6301:14)
    at loadedInit (jquery.dataTables.js:1190:5)
    at HTMLTableElement.<anonymous> (jquery.dataTables.js:1289:5)
    at Function.each (jquery.js:385:19)
    at jQuery.fn.init.each (jquery.js:207:17)
    at jQuery.fn.init.DataTable [as dataTable] (jquery.dataTables.js:846:8)
    at $.fn.DataTable (jquery.dataTables.js:15570:18)
    at $.fn.wireDataTable (datatables.js:233:24)

The code that makes the add call is add( settings.aaSorting );

My options spec, as reported by the console, is as follows:

aaSorting: null
ajax: {url: 'http://localhost/employer/data', data: ƒ}
ajaxData: "d.name = $('#name').val();d.special = $('#special').val();"
aoColumns: (6) [{…}, {…}, {…}, {…}, {…}, {…}]
autoWidth: false
bAutoWidth: false
bFilter: false
bLengthChange: false
bProcessing: true
bServerSide: true
bSort: true
columns: (6) [{…}, {…}, {…}, {…}, {…}, {…}]
emptyTable: "OOPS! Data poll returned no records."
fixedHeader: true
iDisplayLength: 10
language: {decimal: '.', emptyTable: 'OOPS! Data poll returned no records.', info: 'Showing _START_ to _END_ of _TOTAL_ entries', infoEmpty: 'No entries', infoFiltered: '(filtered from _MAX_ total entries)', …}
lengthChange: false
oLanguage: {decimal: '.', emptyTable: 'OOPS! Data poll returned no records.', info: 'Showing _START_ to _END_ of _TOTAL_ entries', infoEmpty: 'No entries', infoFiltered: '(filtered from _MAX_ total entries)', …}
order: null
ordering: true
pageLength: 10
processing: true
responsive: 1
searching: false
serverSide: true
token: "censored"
url: "http://localhost/employer/data"

What is the problem and how do I fix it?

Answers

  • kthorngrenkthorngren Posts: 17,697Questions: 25Answers: 4,197

    Many times this is due to the number of columns defined in HTML doesn't match the number of columns defined in Datatables.. Looks like you have 6 columns in Datatables. Do you have 6 defined in your thead?

    Without seeing a page with the problem is difficult to say what it might be. Please post a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    If you can't do that then maybe a debugger image will help the developers understand the problem.

    Kevin

Sign In or Register to comment.