You should use mData and mRender over fnRender as fnRender will be deprecated in the next DataTables release. But if you want to use fnRender, you provide the "aoColumnDefs" options as follows:
[code]
, "aoColumnDefs": [
{
"aTargets": [7, 8, 9] // <- the effected columns
, "fnRender": function (obj) {
var text= obj.aData[obj.iDataColumn];
if (text == "Y") {
return ""; // <- return what should be rendered
} else {
return ""; // <- return what should be rendered
}
}
, "bUseRendered": false // <- tells DataTables to sort on the original "Y" & "N" values and not the "" tag that is rendered.
}
]
[/code]
Replies
[code]
"aoColumns": [
{
"sClass": "center",
"fnRender": function( oObj ) {
return oObj.aData[0]+' '+ oObj.aData[3];
}
}
]
[/code]
So this will render column 1. If I have a table of 9 columns but only want to render column 7,8,9 and the rest leave as they are, how do you do that?
[code]
"aoColumns": [
{
"sClass": "center",
"fnRender": function( oObj ) {
return oObj.aData[0]+' '+ oObj.aData[3];
}
},
null, //Forname
null, //Surname
null, //Email
null, //REgion
null, //Telephone
null, //Expired
null, //Locked
null, //Logged on
null // created
]
[/code]
[code]
, "aoColumnDefs": [
{
"aTargets": [7, 8, 9] // <- the effected columns
, "fnRender": function (obj) {
var text= obj.aData[obj.iDataColumn];
if (text == "Y") {
return ""; // <- return what should be rendered
} else {
return ""; // <- return what should be rendered
}
}
, "bUseRendered": false // <- tells DataTables to sort on the original "Y" & "N" values and not the "" tag that is rendered.
}
]
[/code]