Uncaught TypeError: Cannot read property 'asSorting' of undefined

Uncaught TypeError: Cannot read property 'asSorting' of undefined

edited April 2012 in General Posts: 4
Hi, I keep getting this error and I'm not sure how to fix it. Here is the code in my html file:
<script type="text/javascript"> $(document).ready( function () { $('#table_id').dataTable( { "aaSorting"= [] "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]], iDisplayLength: 25, iDisplayStart: 3, "oLanguage": { "sZeroRecords": "There are no records that match your search criterion", "sLengthMenu": "Display _MENU_ records per page", "sInfo": "Displaying _START_ to _END_ of _TOTAL_ records", "sInfoEmpty": "Showing 0 to 0 of 0 records", "sInfoFiltered": "(filtered from _MAX_ total records)" }, sPagination: "full_numbers", bStateSave: true, sScorollX: "300px", sScrollY: "200px", oSearch: { "sSearch": "Type here...", "bRegex": false, "bSmart": false } } ); }); </script>


  • It is saying that the error is in the jquery.dataTables.js on line: 6521

    for ( j=0, jLen=oColumn.asSorting.length ; j<jLen ; j++ )
  • In my case I was using DataTables with pivot js and the error was because I hadn't setup column headers properly. Through google I've found that it could also be if you are using <td> instead of <th> in your tbales <thead> in my case my <thead><tr> was empty.
  • Posts: 22,700
    @stantor195 - Can you link us to your page please?

    @larryweya - good to hear you found a solution tot he problem you had. With DataTables 1.9 you should be able to use TH and TD elements interchangeably with DataTables - either should work fine :-)

  • Posts: 22,700
    Cannot connect to server I'm afraid... :-). Is it only up for part of the day?

  • Posts: 1
    This error is generated when no <thead> section is provided. Make sure you have one in your table!
  • I had this problem when I incorrectly defined my aaSorting like this:
    "aaSorting": [0, 'asc'] instead of:
    "aaSorting": [[0, 'asc']]
This discussion has been closed.