Reputation: 735
I have a use case where I want to render a anchor link on specific column index. It can achieved using both fnRowCallback and aoColumnDefs.
So I am wondering which one is better and faster.
Code snippets for both the cases :
aoColumnDefs
"aoColumnDefs": [
{
"fnRender": function ( oObj ) {
return '<a href="abc.html">' + oObj.aData[8]+ '</a>';
},
"aTargets": [8]
},
]
fnRowCallback
"fnRowCallback" : function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
$("td:eq(8)", nRow).html('<a href="abc.html">' + aData[8]+ '</a>'
);}
Upvotes: 0
Views: 4355
Reputation: 4304
I believe with the newest builds of datatables fnRender is deprecated , you should be using mData and mRender
mRender is preferred for use over FnRowCallback on server-side implementations to create urls from data
here is an example, add it to aoColumns for the field, and remove the FnRowCallback
{ "mData": null ,
"mRender" : function ( data, type, full ) {
return '<a href="abc.html">'+full[8]+'</a>';}
},
Docs: http://www.datatables.net/release-datatables/examples/advanced_init/column_render.html
Upvotes: 1