Add ID to TR element after row is dynamically added
Add ID to TR element after row is dynamically added
peterbra
Posts: 7Questions: 0Answers: 0
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 !
[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 !
This discussion has been closed.
Replies
[code]
var theNode = $('#table-groups').dataTable().fnSettings().aoData[addId[0]].nTr;
theNode.setAttribute('id','entry'+$_returnvalue.entryid);
[/code]