Add a row to a table, then update the attributes of the row. : fnCreatedRow ?

Add a row to a table, then update the attributes of the row. : fnCreatedRow ?

btBillbtBill Posts: 31Questions: 0Answers: 0
edited February 2013 in General
I have a table that is initialized on load. The data is setup in the table correctly and things are wonderful.

A person wants to add a record. They click a button, a modal opens, add the info, and then the record should be added to the table behind the modal with the new records ID in the attribute of the row.

Currently I have this for the initial setup:
[code]
pageTable.table = $('table#'+pageTable.tableId).dataTable({
"bPaginate" : false,
"bJQueryUI" : true,
"bDestroy" : true,
"bSort" : true,
"bFilter" : false,
"oLanguage" : {
.....
"sInfo" : ''
},
"aaSorting" : [[ 0, "asc" ]],
"aoColumns" : [
{ "sClass" : "text" },
{ "sClass" : "text" },
{ "sClass" : "text", "bSortable": false }
],
"fnDrawCallback" : pageTable.__resetWitdh // restore original width of UI elements
});
[/code]


When a new record is added I am calling this:
[code]
addRowToTable : function(data)
{
$('#'+pageTable.tableId).dataTable({
"bRetrieve" : true,
"fnCreatedRow" : function( nRow, aData, iDataIndex ) {
alert ('fnCreatedRow : '+iDataIndex);
nRow.setAttribute("recId", data['rectId']);
}
}).fnAddData( [
data['name'],
data['versionNumber'],
''
]
);
[/code]

The Data is added to the table and things look good. The only issue is that the "fnCreatedRow" does not fire.
If i remove the 'bRetreive' it throws off much of the page.

How do I get the "fnCreatedRow" to work only on changes made to the table when rows are added, but not on the initial rendering of the table?

OR

How can i add a row attribute when new data (rows) are added to the set?

Thanks.

Replies

  • btBillbtBill Posts: 31Questions: 0Answers: 0
    Any info would be greatly appreciated.
    Thanks.
This discussion has been closed.