What has fnAddData+fnRender been replaced with in >1.10?
What has fnAddData+fnRender been replaced with in >1.10?
As I'm updating our code using datatables <1.10, I'm having trouble finding a method for the replacement way to use to the fnAddData function.
Right now, we pass in an array that looks like this:
var data = [
{
"field":"value1",
}
,{
"field":"value2",
},{
"field":"value3",
}
]
pass in the above object doing something like:
$dataTable.fnAddData(data);
and three render functions in our aoColumnDefs options;
"aoColumnDefs": [
{
"fnRender": function (oObj) {
var result = '';
var info = oObj.aData[1];
// Do render
return result;
},
"aTargets": [0]
},
{
"fnRender": function (oObj) {
var result = '';
var info = oObj.aData[2];
// Do render
return result;
},
"aTargets": [1]
},
{
"fnRender": function (oObj) {
var result = '';
var info = oObj.aData[3];
// Do render
},
"aTargets": [2]
}
]
So each function gets all of the data, but we only need to access one element in the array for each column.
What is the preferred way to achieve this without using fnRender/render functions now that fnRender is deprecated?
Answers
I know this is the free side of the forum, but I'm in urgent need of help! Thanks for whatever you can offer!!
There is a conversion guide here. In short,
fnAddData
will still work, butrows.add()
is the new API if you want to use the new API style.fnRender
however is gone completely (and good riddance :-) ) - the upgrade document suggests usingcolumns.render
.Allan