a.aoColumns[e] is undefined

a.aoColumns[e] is undefined

JustinTimeJustinTime Posts: 4Questions: 0Answers: 0
edited May 2011 in General
Hey there,

I have a problem which I cannot seem to find the solution for. In short, I have set a specific column I want to sort by "num-html" using the DataTables plugin here: http://datatables.net/plug-ins/sorting#numbers_html

I have included this code at the top of my JS file and set the sorting for this column through aoColumns in the DataTables initialization. Here is my initialization:

[code]
results_table = $('#course_results').dataTable({
"bInfo": true,
"sPaginationType": "full_numbers",
"bRetrieve": true,
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 2, 3, 4 ] } ],
"aoColumns": [
null,
null,
null,
null,
null,
null,
{ "sType": "num-html" }
]
});
[/code]

The sorting on my 7th column works fine, but when I try to sort by my 4th column (which I am sorting manually with hidden columns) I get this error in Firebug (on Firefox 4):

a.aoColumns[e] is undefined
http;//vps.pottersschool.net/Behavior/js/jquery.dataTables.min.js - Line 82

If I remove the aoColumns piece from my DataTables initialization, however, my 4th column sorts fine. However, the 7th column does not sort in the way I need it to. I am not sure why this is occuring. Perhaps I am missing something silly, but I really have no clue.

You can view my page here: http://vps.pottersschool.net/Structure/courses_page.html

Any help would be greatly appreciated! Let me know if you need anything else before you can help me. Thanks!
-Justin

Replies

  • JustinTimeJustinTime Posts: 4Questions: 0Answers: 0
    Also forgot to mention, I am using DataTables version 1.7.6
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Thanks for the link :-). There are 13 defined in the plain HTML but you've only got 7 in aoColumns. Indeed DataTables is throwing a Javascript error:

    [code]
    DataTables warning (table id = 'course_results'): Unexpected number of TD elements. Expected 126 and got 252. DataTables does not support rowspan / colspan in the table body, and there must be one cell for each row/column combination.
    [/code]
    aoColumns must be the same length as the number of columns defined in the HTML. You can use bVisible to hide columns if you need to.

    Allan
  • JustinTimeJustinTime Posts: 4Questions: 0Answers: 0
    Ah, I thought I missed something stupid like that. Thanks so much for the quick reply! Making aoColumns the same length as the true # of columns in my HTML fixed the problem.

    -Justin
This discussion has been closed.