Add ID to TR element after row is dynamically added

Add ID to TR element after row is dynamically added

peterbrapeterbra Posts: 7Questions: 0Answers: 0
edited January 2013 in DataTables 1.9
Init is pretty much basic:

[code]
$('#table-groups').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bFilter": false,
"bInfo": false,
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"aoColumns": [
{ "sClass": "name" },
{ "sClass": "tools", "bSortable": false},
],
});
[/code]

Now I have a server-side script that will return me Json like this:
[code]{"response":"OK","entryid":"83","name":"Testinggroup"} [/code]

Now I have a function that adds a row in DataTable

[code]
$('#table-groups').dataTable().fnAddData( [""+$_returnvalue.name+"","Edit settingsDelete"]);
[/code]

And all works well, but I need to add ID to the newly created element (id should be enrtryid that I have $_returnvalue.entryid )

Any ideas how to achieve this ?

Thanks a lot !

Replies

  • peterbrapeterbra Posts: 7Questions: 0Answers: 0
    In a case that anyone has same problem, I solved it like:
    [code]
    var theNode = $('#table-groups').dataTable().fnSettings().aoData[addId[0]].nTr;
    theNode.setAttribute('id','entry'+$_returnvalue.entryid);
    [/code]
This discussion has been closed.