.row() returning wrong row from .cell( element )

.row() returning wrong row from .cell( element )

NewLISTNewLIST Posts: 7Questions: 3Answers: 0

I think I may have found a bug in the latest version of DataTables. When calling the following code in a two-row table:

var rowData = $('#mytable').DataTable().cell( element ).row().data();

DataTables returns only the first row. I can console log that DataTables is getting the right .cell( element ), but then when it grabs the .row() it returns the first row instead of the second. Here's the debug link.

https://debug.datatables.net/ukevox

-Beau

Replies

  • allanallan Posts: 56,187Questions: 1Answers: 8,897 Site admin

    Hi Beau,

    Using row() like that is actually just using row() without a selector. So it is selecting all rows and then truncating it to the first row found.

    What you want is:

    var rowData = $('#mytable').DataTable().row( element.parentNode ).data();
    

    Allan

  • NewLISTNewLIST Posts: 7Questions: 3Answers: 0

    Okay, cool. That works. That's probably what I get for coding at 3:00 AM. ;)

    You can close this, Allan. Thanks again!

This discussion has been closed.