[Unable to get value of the property 'nTr': object is null or undefined] in 1.9, in 1.8.2 works fine

[Unable to get value of the property 'nTr': object is null or undefined] in 1.9, in 1.8.2 works fine

etasoftetasoft Posts: 3Questions: 0Answers: 0
edited April 2012 in Bug reports
Hello, i have a trouble with jquery datatables, have a table where dinamically i created some rows, there are 4 columns and the last column is this:

[code] X [/code]

and i have this function:

[code] function deleteRow(objj) {
var aPos = oTable.fnGetPosition(objj.parentNode);
oTable.fnDeleteRow(aPos[0]);
};
[/code]

in datatables v1.8.2 this code works fine, but in version 1.9 i got this error (IE9 on Windows7):

[quote]
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
Timestamp: Mon, 2 Apr 2012 20:31:06 UTC

Message: Unable to get value of the property 'nTr': object is null or undefined
Line: 94
Char: 86
Code: 0
URI: http://localhost/sysven/js/jquery.dataTables.min.js
[/quote]

looks like oTable.fnGetPosition does not find the correct in order to delete the row, i test this one

[code] var aPos = oTable.fnGetPosition(objj.parentNode.parentNode); [/code]

and its not work either

would you suggest another way to get the parent ???

thanks in advance...

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Although that should work in 1.9 (it would be great if you can link me to a test case showing the issue please), I'd suggest you use something like this:

    [code]
    function deleteRow(objj) {
    oTable.fnDeleteRow( $(objj).parents('tr')[0] );
    };
    [/code]

    as it is a lot more flexible.

    Allan
  • etasoftetasoft Posts: 3Questions: 0Answers: 0
    Hi Allan, thanks for response, but it does not work, sorry….

    I tried your suggestion:

    [code]function deleteRow(objj) {
    oTable.fnDeleteRow( $(objj).parents('tr')[0] );
    };
    [/code]

    a variation:

    [code]function deleteRow(objj) {
    var tr = $(objj).parents('tr')[0];
    oTable.fnDeleteRow( tr, false );
    };
    [/code]

    Also tried:

    [code]function deleteRow(objj) {
    var aPos = $(objj).parents("tr").eq(0)
    oTable.fnDeleteRow(aPos[0]);
    };
    [/code]

    using closest() neither worked….

    I repeat the issue with the non mini library and the error line is 1325:

    [quote]Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
    Timestamp: Tue, 3 Apr 2012 13:17:09 UTC

    Message: Unable to get value of the property 'nTr': object is null or undefined
    Line: 1325
    Char: 6
    Code: 0
    URI: http://localhost/sysven/js/jquery.dataTables.js
    [/quote]

    error Line is:
    [code] if ( aoData.nTr === null )[/code]

    of function _fnDraw( oSettings )

    but also, I compared both same name function in 1.9 and 1.8.2 version and the main differences in code are relating to pre-callback function this one:

    /* Provide a pre-callback function which can be used to cancel the draw is false is returned */

    Back this, the code is the same more or less 100 lines including the 1325, until the callback function…

    I think would be a good idea, rethink the logic to delete the row, maybe using classes or binding a live event to “a” tag inside the td , but by moment, I’ll downgrade to v1.8.2 because I’m urged to finish the project, but next week I’ll prepare for you a replica of work scenary to replicate the error, now is a little complicated for me, because this page is programmed using classic asp and sql server as background database also is on client’s intranet and behind a firewall, there is not access from internet . So I have to replicate to internet part of site and database, send you links and also a ftp credentials for total control and describe the steps to recreate the error..

    best regards
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    That error suggests that a draw is occurring but the display arrays in DataTables haven't been updated to take account of the deleted row.

    Can you link me to a test page showing the problem or use http://live.datatables.net to put up an example please? I've been using fnDeleteRow a lot recently and haven't hit this problem, so to be able to address it, I'll need a way of reproducing the error.

    Thanks,
    Allan
  • etasoftetasoft Posts: 3Questions: 0Answers: 0
    mmmm, i see, it looks like exactly you write...

    I read somewhere that running the function fnDeleteRow with second parameter false avoided the redraw, but it seems that, at least in this case, the management of the callback function overdrive this behavior

    i was seen http://live.datatables.net but its insufficient to recreate the error because the same just happen at dinamically load of rows, the page has 2 modes, one to edit multiples rows and other to add one by one, in first case, no problem to add or delete rows but in second case, i just notice that add one row, and inmediately try to delete this one fire the error, in v1.8.2, the row deletion is ok in any case

    regrettably the page is behind a firewall in client' intranet, so, there is no way to access from internet, sorry

    next week I'm going to replicate online the page relates to the error and send you the link and access to review the problem..

    best regards
    thanks very much
This discussion has been closed.