row().data() method not working.

row().data() method not working.

adninjazzadninjazz Posts: 4Questions: 2Answers: 0

I tried the code -

$('#NACH-User-Table').on( 'click', 'tr', function () {
var userId = table.row( $(this).parents('tr') ).data();
alert( "UserID = "+userId[0] );
} );

But getting UserID = undefined.

This question has an accepted answers - jump to answer

Answers

  • adninjazzadninjazz Posts: 4Questions: 2Answers: 0

    Actually, I want complete row data on click.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @adninjazz ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,947
    Answer ✓

    I think you should be able to use simply this to get the row:
    var userId = table.row( this ).data();

    Kevin

  • adninjazzadninjazz Posts: 4Questions: 2Answers: 0

    Umm!!! Actually it worked when I changed this line -

    alert( "UserID = "+userId[0] );

    to

    alert( "UserID = "+userId.UserID );

    Its giving the info now.
    Thanks for the help everyone.

This discussion has been closed.