Assigning fnRowCallback after the dataTable() call
Assigning fnRowCallback after the dataTable() call
I've seen many examples of having the fnRowCallback defined as part of the dataTable() call, but is it possible to add this later?
Say I have this:
[code]oTable = $("table#summary").dataTable();[/code]Is it possible to do something like
[code]oTable.fnRowCallback = function(nRow,aData,iDisplayIndex) {
keyids = new Array(0);
var id = "";
for (k in keyids) id = id.concat(aData[k],",");
if (id.charAt(id.length-1)) = ",") id = id.substring(0,id.length-1);
$(nRow).attr("id",id);
return nRow;
}[/code]This doesn't work, and I can't figure out if that's even possible. Is there a valid syntax to assign the callback function after the initialization?
Say I have this:
[code]oTable = $("table#summary").dataTable();[/code]Is it possible to do something like
[code]oTable.fnRowCallback = function(nRow,aData,iDisplayIndex) {
keyids = new Array(0);
var id = "";
for (k in keyids) id = id.concat(aData[k],",");
if (id.charAt(id.length-1)) = ",") id = id.substring(0,id.length-1);
$(nRow).attr("id",id);
return nRow;
}[/code]This doesn't work, and I can't figure out if that's even possible. Is there a valid syntax to assign the callback function after the initialization?
This discussion has been closed.
Replies
[code]
var oTable = $("table#summary").dataTable();
var oSettings = oTable.fnSettings();
oSettings.fnRowCallback = function (...){...};
[/code]
It's worth noting that this uses some of DataTables internals, so it is possible that this might change in future (although unlikely in the near future - it's been there since 1.0.0!).
Regards,
Allan