setting TD ID after using fnAddData
setting TD ID after using fnAddData
Hi,
My initial data is loaded with a PHP loop so I am able to set the IDs by printing the TDs myself.
However I use fnAddData to add new rows after that and I need to set the IDs of the newly added TDs.
I saw an older poster referring to this code:
[code]
var newRow = oTable.fnAddData( [data] );
var oSettings = oTable.fnSettings();
var nTr = oSettings.aoData[ newRow[0] ].nTr;
[/code]
But I'm unsure of the correct syntax of the code to follow to set the ID attribute of a particular TD.
My attempt was
[code]
nTr.children(":nth-child(0)").setAttribute("id", "address__" + "dynamiccontent");
[/code]
but that does not work.
Please help.
Thanks
My initial data is loaded with a PHP loop so I am able to set the IDs by printing the TDs myself.
However I use fnAddData to add new rows after that and I need to set the IDs of the newly added TDs.
I saw an older poster referring to this code:
[code]
var newRow = oTable.fnAddData( [data] );
var oSettings = oTable.fnSettings();
var nTr = oSettings.aoData[ newRow[0] ].nTr;
[/code]
But I'm unsure of the correct syntax of the code to follow to set the ID attribute of a particular TD.
My attempt was
[code]
nTr.children(":nth-child(0)").setAttribute("id", "address__" + "dynamiccontent");
[/code]
but that does not work.
Please help.
Thanks
This discussion has been closed.
Replies
[code]
$('td', nTr)[0].setAttribute( 'id', ... );
[/code]
Other methods could use getElementsByTagName etc - all achieving the same thing.
Hope that helps!
Allan