Column Sorting Error

Column Sorting Error

antivanityantivanity Posts: 6Questions: 0Answers: 0
edited May 2009 in Bug reports
I get this error on all datatables iv made. It occurs when sorting a column, not sure whats going on. Please help ;)

ERROR:
oSettings.aoData[iRow] is undefined
[Break on this error] return oSettings.aoData[iRow]._aData;

CODE:
$(document).ready(function(){
myDataTable = $('#datatable').dataTable( {
"sPaginationType": "full_numbers"
});
$('#dataloader').hide();
$('#datatable tr').click( function(e) {
var position = myDataTable.fnGetPosition(this); // getting the clicked row position
var contactId = myDataTable.fnGetData(position)[0]; // getting the value of the first (invisible) column
document.location.href = "/account/view/" + contactId;
});
});

Replies

  • antivanityantivanity Posts: 6Questions: 0Answers: 0
    Fixed it, had to make sure posision wasnt null before calling fnGetData()..

    $('#datatable tr').click( function(e) {
    var position = myDataTable.fnGetPosition(this); // getting the clicked row position
    if (position != null)
    {
    var contactId = myDataTable.fnGetData(position)[0]; // getting the value of the first (invisible) column
    document.location.href = "/admin/useredit/" + contactId;
    }
    });
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    That's a funny one. If your TR is the only element with an event handler then I would have expected it to work with your original code. The only thing which springs to mind is that there might be some event bubbling going on and that the 'this' inside your event handler isn't actually the TR, but rather the element that was clicked on (TD, IMG whatever).

    However, if it's now working as expected - that will do nicely ;-)

    One thing to note, you might want to use '#datatable tbody tr' as your selector, as at the moment it will include the header row - which would return null from fnGetPosition().

    Allan
  • antivanityantivanity Posts: 6Questions: 0Answers: 0
    Duh! $('#datatabe tbody tr') is much more elegant, im retarded ;)

    Thanks allan!
This discussion has been closed.