Dynamically add ID's to each row

Dynamically add ID's to each row

TanaxTanax Posts: 9Questions: 0Answers: 0
edited January 2012 in General
I read here: http://datatables.net/release-datatables/examples/server_side/ids.html

Unfortunately, I am adding data to the table dynamically like this:
[code]
$('#friends_lost').dataTable().fnAddData([
textout.name,
beg + 'true, ' + textout.id + end,
'Not lost'
]);
[/code]

How would I go about to add an ID or class to this datarow that I'm feeding into the table?

Kind regards,
Tanax

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Same basic idea, just pass in an object with the required parameters set:

    [code]
    $('#friends_lost').dataTable().fnAddData( {
    "DT_RowId": "myId",
    "0": textout.name,
    "1": beg + 'true, ' + textout.id + end,
    "2": 'Not lost'
    } );
    [/code]

    Allan
  • TanaxTanax Posts: 9Questions: 0Answers: 0
    This worked great, thank you so much Allan!
This discussion has been closed.