Cannot read property 'asSorting' of undefined in dataTables 1.9?

Cannot read property 'asSorting' of undefined in dataTables 1.9?

tleithofftleithoff Posts: 1Questions: 0Answers: 0
edited April 2012 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?

Replies

  • encodedencoded Posts: 4Questions: 0Answers: 0
    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.
  • encodedencoded Posts: 4Questions: 0Answers: 0
    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.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    There is no THEAD element, which is a prerequisite of DataTables: http://datatables.net/usage/#prerequisites

    Allan
  • encodedencoded Posts: 4Questions: 0Answers: 0
    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?
  • encodedencoded Posts: 4Questions: 0Answers: 0
    Sorry, the updated fiddle can be found at http://jsfiddle.net/SFRXL/6/
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    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:

    [code]
    $("").dataTable();
    [/code]

    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.