Sort by column header causes error on every other use

Sort by column header causes error on every other use

PaoloValladolidPaoloValladolid Posts: 35Questions: 0Answers: 0
edited November 2010 in Bug reports
I can click a column to sort without any errors. When I click the same column again I get this message:

Line: 1725
Error: 'aoData[...]._aData' is null or not an object

According to the Internet Explorer javascript debugger, the error seems to occur within this block of code in the jquery.dataTables.js file:

this.fnGetData = function( mRow )
{
var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );

if ( typeof mRow != 'undefined' )
{
var iRow = (typeof mRow == 'object') ?
_fnNodeToDataIndex(oSettings, mRow) : mRow;
return oSettings.aoData[iRow]._aData; //<-- ERROR at Line 1725
}
return _fnGetDataMaster( oSettings );
};

Is there a workaround? The data was loaded from the database using JSTL tags to output data into the table.

Replies

  • PaoloValladolidPaoloValladolid Posts: 35Questions: 0Answers: 0
    I tried simplifying the Datatable content in the following manner. There should be nothing in the data to cause the error - it's just a row of 1s, followed by a row of 2s, etc.:

    [code]




    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}
    ${status.count}



    [/code]

    I also double-checked that the number of columns in matches the number of headers in

    Here is the table configuration:

    [code]
    var searchResultTable;

    $(document).ready(function() {
    /* Add a click handler to the rows - display package number and description below */
    $('#searchResultTable tr').click( function() {
    if ( $(this).hasClass('row_selected') ){
    $(this).removeClass('row_selected');
    document.getElementById('detail_0').value="";
    document.getElementById('detail_1').value="";
    var numRows = searchResultTable.fnGetData().length;
    for (var i=0; i < numRows; i++) {
    var node = searchResultTable.fnGetNodes(i);
    if ($(node).hasClass('row_selected')) {
    var aPos1 = searchResultTable.fnGetPosition(node);
    var aData1 = searchResultTable.fnGetData(aPos1);
    document.getElementById('detail_0').value = aData1[15];
    var packageDescription = aData[14].replace(/&/g,'&');
    document.getElementById('detail_1').value = packageDescription;
    }
    }
    }
    else {
    $(this).addClass('row_selected');
    var aPos = searchResultTable.fnGetPosition(this);
    var aData = searchResultTable.fnGetData(aPos);
    document.getElementById('detail_0').value = aData[15];
    var packageDescription = aData[14].replace(/&/g,'&');
    document.getElementById('detail_1').value = packageDescription;
    }
    } );


    searchResultTable =
    $('#searchResultTable').dataTable( {
    "bProcessing": true,
    "sPaginationType": "full_numbers",
    "bFilter": false,
    "aoColumnDefs": [
    { "bVisible": false, "aTargets": [ 13, 14, 15 ] }
    ]
    } );
    } );
    [/code]
  • PaoloValladolidPaoloValladolid Posts: 35Questions: 0Answers: 0
    The problem was in the click handler code, caused by aPos being null. Adding lines such as the following eliminated the error:


    [code]
    var aPos1 = searchResultTable.fnGetPosition(node);
    if (aPos1 == null) {
    return;
    }
    [/code]
This discussion has been closed.