own td attribute(s)
own td attribute(s)
Hi, i'm googling since this morning and I can't find an answer to my problem.
I've seen somewhere in this forum that i can add class or id attribute to a newly generated TR/TD.
I've seen that i could add an other kind of attribute in my TR/TD using fnAddData like this
var ai = oTable.fnAddData( a );
var n = oTable.fnSettings().aoData[ ai[0] ].nTr;
nTr.attr('foo', 'bar');
But, when data come from server (bServerSide = true), how can i fire this ?
It's really unfortunate that we can't add custom property easily as we can add id or class to newly generated TR/TD :)
I've seen somewhere in this forum that i can add class or id attribute to a newly generated TR/TD.
I've seen that i could add an other kind of attribute in my TR/TD using fnAddData like this
var ai = oTable.fnAddData( a );
var n = oTable.fnSettings().aoData[ ai[0] ].nTr;
nTr.attr('foo', 'bar');
But, when data come from server (bServerSide = true), how can i fire this ?
It's really unfortunate that we can't add custom property easily as we can add id or class to newly generated TR/TD :)
This discussion has been closed.
Replies
fnDrawCallback is called after a draw (after all rows rendered)
use one of the callbacks. I recommend fnRowCallback, which passes you the DOM node (TR) as nRow.
[code]
$(document).ready(function() {
$('#example').dataTable( {
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
$(nRow).attr('foo', 'bar');
return nRow;
}
} );
} );
[/code]
http://datatables.net/release-datatables/examples/server_side/ids.html
and documented here:
http://datatables.net/usage/server-side
Allan