columndefs if condition code example
Example: columndefs if condition
"columnDefs" : [ {
"targets" : [ 3, 4, 5 ],
render : function(data, type, row, meta) {
if (meta.col == 4) {
if (data == 1) {
return 'Test1';
} else if (data == 2) {
return 'Test2';
}
} else if (meta.col == 3 || meta.col == 5) {
if (data == null || data == "") {
return "";
} else {
return data;
}
}
},
} ],
"columnDefs" : [ {
"className" : "dt-center",
"targets" : "0"
} ],