Uncaught TypeError: Cannot read property 'nTr' of undefined

Uncaught TypeError: Cannot read property 'nTr' of undefined

bootlebootle Posts: 5Questions: 0Answers: 0
edited May 2011 in DataTables 1.8
Using Google Chrome 11.

Am new to DT, however have just started a project using 1.7.6, and is here:

http://www.bootleblog.com/test/
(click on markets, updates are every two seconds)

When I use the same code with 1.8.0 beta 3, get the error messages.

http://www.bootleblog.com/180beta3/

here's where the exception occurs...

[code]
for ( iRow=iStart ; iRow

Replies

  • bootlebootle Posts: 5Questions: 0Answers: 0
    Hi there,

    I debugged into DataTables where the error was occuring, and noted iEnd becomes 11, not 4.

    [code]
    line 5876
    function _fnGetTdNodes ( oSettings, iIndividualRow )
    {
    var anReturn = [];
    var iCorrector;
    var anTds;
    var iRow, iRows=oSettings.aoData.length,
    iColumn, iColumns, oData, sNodeName, iStart=0, iEnd=iRows; // <<<<< iRows = 4

    /* Allow the collection to be limited to just one row */
    if ( typeof iIndividualRow != 'undefined' )
    {
    iStart = iIndividualRow;
    iEnd = iIndividualRow+1; // <<<<<<<<<<<<<<< iIndividualRow = "1", so "1" + 1 = 11, ooooops!
    }

    for ( iRow=iStart ; iRow
  • bootlebootle Posts: 5Questions: 0Answers: 0
    Ah, the power of open-source!

    I hacked line 5891 to limit the loop to iRows, not iEnd. Does the trick for me, but no doubt there was a reason for calculating iEnd, so will leave it to you to update correctly, with your unit tests. Maybe need a new unit test in this area - how come it passed? ;-)

    [code]
    function _fnGetTdNodes ( oSettings, iIndividualRow )
    {
    var anReturn = [];
    var iCorrector;
    var anTds;
    var iRow, iRows=oSettings.aoData.length,
    iColumn, iColumns, oData, sNodeName, iStart=0, iEnd=iRows;

    /* Allow the collection to be limited to just one row */
    if ( typeof iIndividualRow != 'undefined' )
    {
    iStart = iIndividualRow;
    iEnd = iIndividualRow+1;
    }

    // for ( iRow=iStart ; iRow
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    I see - so the basic issue is that 'rowid' that you are passing into fnUpdate is a string rather than an integer? The problem with that is that fnUpdate isn't expecting a string - it is looking for an integer or a DOM node. Currently it looks like giving it a string results in undefined behaviour (and weird things happen as you are seeing). So the question is, why pass in a string to fnUpdate?

    Regards,
    Allan
  • bootlebootle Posts: 5Questions: 0Answers: 0
    Thanks, spot on. Going back to the server side and making sure row IDs for updates are being outputted as integers (via JSON) did the trick. Many thanks!
  • enigma387enigma387 Posts: 1Questions: 0Answers: 0

    Wow.Bang on! Thanks. Solved my issue I was passing string instead of int to fnUpdate

This discussion has been closed.