I use jQuery DataTable in my ASP.NET MVC project. One of my databasecolumns gives true/false values. I want to translate its value to a string and changes its color. I tried following code for this column:
"columns": [
{"data":"pmId"},
{"data":"pmNumber"},
{"data":"costCenter"},
{"data":"serviceType"},
{"data":"destination"},
{"data":"workCenter"},
{"data":"creationDate"},
{"data":"creationTime"},
{"data":"startDate"},
{"data":"endDate"},
{"data":"mainFileName"},
{"data":"returnDate"},
{"data":"returnTime"},
{"data":"status"},
{"data":"fileName"},
{"data":"uploader"},
{
"data":"isDownloaded",
"render": function(data){
if(data == true){
"display": "Downloaded"
}else{
"display": "Not Downloaded"
}
}
},
{
"render": function(data, type, full, meta) { return '<a class="btn btn-info" href="/DemoGrid/Edit/' + full.CustomerID + '">Edit</a>'; }
},
{
data: null,
render: function(data, type, row) {
return `<a href='#' class='btn btn-danger' onclick="DeleteData('${row.pmId}', '${row.mainFileName}', '${row.fileName}')";>Delete</a>`;
}
}
],
The problem is that it does not work.
What I have tried:
I used the following code:
{
"data":"isDownloaded",
"render": function(data){
if(data == true){
"display": "Downloaded"
}else{
"display": "Not Downloaded"
}
}
},