setting TD ID after using fnAddData

setting TD ID after using fnAddData

jriverajrivera Posts: 14Questions: 0Answers: 0
edited February 2010 in General
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

Replies

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin
    There are a number of ways to do this - the easiest is with a jQuery selector:

    [code]
    $('td', nTr)[0].setAttribute( 'id', ... );
    [/code]
    Other methods could use getElementsByTagName etc - all achieving the same thing.

    Hope that helps!
    Allan
This discussion has been closed.