Add data attribute for row

Add data attribute for row

rickburgenrickburgen Posts: 2Questions: 1Answers: 0

Hi all:
I'm manually inserting new rows into a table using
$("#table_cases").DataTable().row.add([temp.info1, temp.info2, temp.info3, temp.info4, temp.info5, temp.info6]);

I also would like to add a data attribute to each row. Because I have a click function for each row, and I need to retrieve this attribute value from.

I've done a bunch of research yesterday, but nothing I found would work. Any ideas on how I can accomplish this?

Thanks!

Answers

  • rickburgenrickburgen Posts: 2Questions: 1Answers: 0

    What I ended up doing was

    var temp = $("#table_cases").DataTable().row.add([temp.info1, temp.info2, temp.info3, temp.info4, temp.info5, temp.info6]).node();

    $(temp).attr("data-value", temp.info7);

This discussion has been closed.