Can someone confirm if I am using the if statement correctly in this script? Or is it not possible to use an if statement within this code?
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
$('#customerTable').dataTable({
"bServerSide": true,
"sAjaxSource": "Customer/AjaxHandler",
"bProcessing": true,
"aoColumns": [{
"sName": "CustomerId",
"bVisible": false
}, {
"sName": "NamaPerusahaan",
"bSearchable": true,
"bSortable": true,
"fnRender": function (oObj) {
return '<a href="/Customer/Details/' +
oObj.aData[0] + '">' + oObj.aData[1] + '</a>';
}
}, {
"sName": "Alamat1"
}, {
"sName": "Telephone"
},
//below is the datetime
{
"sName": "NonActiveDate",
"bSearchable": true,
"bSortable": true,
"fnRender": function (oObj) {
if(oObj.aData[4] <= @DateTime.Now) {
return '<span style="color:green">' + oObj.aData[4] + ' </span>';
} else {
return '<span style="color:red">' + oObj.aData[4] + ' </span>';
}
}
}, {
"sName": "Edit",
"bSearchable": false,
"bSortable": false,
"fnRender": function (oObj) {
return '<a href="/Customer/Edit/' + oObj.aData[0] + '" class="btn mini blue"><i class="icon-edit"></i>Edit</a>';
}
}, {
"sName": "Delete",
"bSearchable": false,
"bSortable": false,
"fnRender": function (oObj) {
return '<a href="/Customer/Edit/' + oObj.aData[0] + '" class="btn mini red"><i class="icon-trash"></i>Delete</a>';
}
}
]
});
});
</script>
The font color for TglNonAktif becomes all green with this code. I suspect there might be an issue with the if statement. Any assistance would be greatly appreciated!