nTh.parentNode is null

nTh.parentNode is null

ruzzruzz Posts: 49Questions: 0Answers: 0
edited August 2010 in General
Hi Allan/all,

I've read this, http://datatables.net/forums/comments.php?DiscussionID=2352&page=1#Item_0
but it's not my problem - THs match my aoColumns perfectly (eleven, in this case). What I've done to reveal the error is added "bDestroy":true. When I open the table first time, everything is fine. When I try to re-open the table I get the error.

What I'm trying to achieve is getting a fresh set of data each time the table is opened/called. (I thought bRetrieve would work but apparently not).

Allan - Any ideas why _fnDrawHead is getting this wrong? My debugging here reveals...
oSettings.aoColumns.length == 11 (correct, there are 11 THs in the HTML and 11 entries in aoColumns)
iThs == 3 (correct for 3 visible columns - they happen to be indexes 0, 1, and 2 which helps for debugging)
Watching _fnDrawHead looping, I see your code trying to call .parentNode on a TH with bVisible set to false (and from reading elsewhere on this forum I think you've said non-visible columns are "cached" - i.e. not present in the DOM) So if I understand correctly, the invisible THs live on in oSettings.aoColumns?

Anyway, oSettings.aoColumns[<3 - 10>].nTh.parentNode are all null therefore this line is always going to fail:

nTh.parentNode.removeChild( nTh );

All of which makes me think I must be using the bDestroy setting incorrectly...

TIA
ruzz

Replies

  • ruzzruzz Posts: 49Questions: 0Answers: 0
    Interestingly, this:
    [code]
    oTableHistory.fnDestroy()
    [/code]
    works fine - same table, same "destroy" (I'd expect, anyway) but no errors. Baffling.

    ruzz
  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
    Hi ruzz,

    Thanks for posting this - most certainly a bug in DataTables. What the problem appears to be is that when fnDestroy is called, DataTables is not restoring any columns which have been hidden correctly (at all in fact). This results is some very odd behaviour. The good news is I have a fix for this and I hope to do a release later on today.

    Regards,
    Allan
  • brucebruce Posts: 3Questions: 0Answers: 0
    Hi,

    is it possible that this bug isn't completely fixed?
    I'm using a DataTable with some hidden columns and need to re-initialise it sometimes when a user clicks a special link (because the sAjaxSource changes).
    At first I have 5 visible and 3 hidden columns, everything is fine and I see 5 columns.
    After the first re-initialisation (with "bDestroy": true) only two columns remain visible in the column header section, the body of the table remains okay. The next re-initialisation fails. It seems like DataTables is somehow not handling those 3 hidden columns correctly.
    I found out that it happens only under certain circumstances, namely "sScrollY" has to be set and "bServerSide" has to be true.

    Greetings,
    bruce
  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
    Hi Bruce,

    I think you are right - there is an issue here with destroying a table and scrolling - it doesn't correctly restore it. Unfortunatly in tracking this down I've just found another bug (fnInitComplete fires to early when server-side processing) which will need fixing first.

    I'll get back to you on this one...

    Allan
  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
    Hi Bruce,

    Yup there was a couple of things which needed tidying up in this area - but now down. You can grab the latest version from github: http://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js . A couple of unit tests also added to try and make sure it doesn't crop up again :-)

    Regards,
    Allan
  • brucebruce Posts: 3Questions: 0Answers: 0
    Hi Allan,

    Thank you very much for you quick response - I checked it out and it's working now *thumbs up*

    Greetings,
    bruce
This discussion has been closed.