How to set the attribute 'id' on a new row?

How to set the attribute 'id' on a new row?

princeofnaxosprinceofnaxos Posts: 26Questions: 9Answers: 0

When using the option 'rowId', all 'tr' elements get an attribute 'id'. I use this to be able to retrieve data from the database when one clicks the row.

But when I add a new row, the id is not there. When using

$(newrow).attr('id', id)

nothing happens. This means that clicking the row has no effect. How do I get the row to have an 'id' attribute?

This question has an accepted answers - jump to answer

Answers

  • princeofnaxosprinceofnaxos Posts: 26Questions: 9Answers: 0

    Ok, right after posting I got an idea. And solved my problem.

    It appears you jest have to add 'id' to the dataset of table.row.add(). Can't find this in the documentation....

  • allanallan Posts: 64,508Questions: 1Answers: 10,662 Site admin
    edited August 2016 Answer ✓

    You can use createdRow or row().node() to manipulate the row and add the ID.

    It appears you jest have to add 'id' to the dataset of table.row.add(). Can't find this in the documentation....

    If you have the rowId option set to id then yes, that would work. (Edit - corrected option name)

    Allan

This discussion has been closed.