DataTables logo DataTables

Cannot read property 'asSorting' of undefined in dataTables 1.9?
  • Hi, we upgraded our dataTables plugin from the 1.7 version to the 1.9 version, and are getting this error:

    Cannot read property 'asSorting' of undefined

    On tables that are not sortable. All tables that are sortable are fine. Has anyone else had this same problem or know how to fix it?
  • I'm seeing this issue as well, though I've upgraded only from 1.9.2 to 1.9.3. I don't remember seeing it before then.
  • Here's a quick fiddle which displays the behavior: http://jsfiddle.net/SFRXL/1/

    The fiddle uses jQuery 1.7.2 and DataTables 1.9.3 from the MSFT CDN.
  • There is no THEAD element, which is a prerequisite of DataTables: http://datatables.net/usage/#prerequisites

    Allan
  • Thank you for the quick response!

    I have corrected the fiddle, but still the error remains. I have re-read the prerequisites but don't see that I'm missing anything else.

    I tried adding an empty tr to the thead as well, but to no effect. I also added a th inside of the tr in the thead, but also to no effect.

    Any more suggestions?
  • Sorry, the updated fiddle can be found at http://jsfiddle.net/SFRXL/6/
  • The THEAD is used by DataTables to tell it how many columns there are. An empty THEAD isn't going to do that, and DataTables could easily have injected that itself :-).

    http://jsfiddle.net/SFRXL/7/

    The other issue was:

    $("<table>").dataTable();
    

    That creates a 'TABLE' element, rather than selecting the one from the document. Remove the angle brackets to select the table (which /7 does).

    Allan
This discussion has been closed.
All Discussions