Hot to get ID of a newly added row in fnOnAdded

Hot to get ID of a newly added row in fnOnAdded

mathiasmathias Posts: 12Questions: 0Answers: 0
edited August 2011 in General
I use Datatables-Editable and I just implemented DataTables hidden row details ( http://www.datatables.net/release-datatables/examples/api/row_details.html ). That is, I can open a row by clicking an icon to display further information. Now, when I add a new row, I want that icon to be there at the same time the row gets created (I don't want to have to reload the whole page). I think I need to do something like:
[code]
$('#employees tbody tr#'+id).each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );[/code]
in fnOnAdded. Problem is, I don't know how to pass the id to that function?

How do I pass the id to fnOnAdded? And is this the way to go or how should I solve the problem?

Replies

  • rasdnarasdna Posts: 1Questions: 0Answers: 0
    I am looking for the answer to this question as well..
  • joelatijoelati Posts: 1Questions: 0Answers: 0
    Not the most elegant solution, but this worked for me. It relies on finding the added row based on its newly given "last-added-row" class:

    [code]
    fnOnAdded: function()
    {
    var newrowindex = oTable.fnGetPosition($(".last-added-row").closest('tr')[0]);

    var newrowdata = oTable.fnGetData(newrowindex);
    return true;
    }
    [/code]
This discussion has been closed.