fnRowCallback: $(nRow).closest('table').length is zero?

fnRowCallback: $(nRow).closest('table').length is zero?

lancehilliardlancehilliard Posts: 4Questions: 0Answers: 0
edited October 2013 in General
http://jsfiddle.net/weQNd/3/

Why does the console show zero tables?

In my real code, I'm trying from fnRowCallback to modify the header row of the table, but I'm having a hard time getting there since I can't find the table node from the row passed into the callback.

http://debug.datatables.net/usituw

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    The row callback function is called before the element is actually inserted into the document - so that code will work for some rows, if they are already in the document, but not all.

    If you want to modify the header, you probably want to use fnDrawCallback or fnHeaderCallback rather than the row callback function, so that it only runs once per draw, rather than once per row.

    Allan
  • lancehilliardlancehilliard Posts: 4Questions: 0Answers: 0
    Very good. Thank you for the guidance.
This discussion has been closed.