How do I pull data from a different column on the same row?

How do I pull data from a different column on the same row?

jordonshawjordonshaw Posts: 23Questions: 9Answers: 0
edited June 2022 in DataTables 1.10

I have a users table and I want to create a switch for status that someone can click on and it changes the user from active to inactive. I have the programming working correctly from that standpoint; however, for some reason, all of my users are getting the same user information, which happens to be the last user in my results. I need a way to specify to pull the data from the actual row it's on, not the last row in my results. Here is my current code I'm using:

How do I get the data from the row I'm currently on?

Thanks so much!
Jordon

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949
    Answer ✓

    The columns.render function runs for each row when the table is built. In that function you have page elements you are populating with the data. If you have 10 rows, for example, then those elements will be updated 10 times; one for each row with the last result being displayed.

    Do you want to populate these elements when the row is clicked on? If so this example shows how to get the row data of the clicked row. Move your columns.render code into the click event to populate the elements when clicked.

    Kevin

  • jordonshawjordonshaw Posts: 23Questions: 9Answers: 0

    @kthorngren, Thanks for your help! I was able to do what I want through the click event. It worked great.

    Jordon

Sign In or Register to comment.