I am new to JS BS Datatables, is this the right way to parseInt for if else statement?
$(document).ready(function() {
$('#myTable').DataTable({
"order": [],
"columnDefs": [{
"targets": 'nosort',
"orderable": false,
}],
"fnRowCallback": function(nRow, aData) {
if (parseInt(aData[7].innerHTML,10) <= 30) {
$('td', nRow).css('background-color', 'Red');
} else if (aData[2] >= "30" && aData[2] < "50") {
$('td', nRow).css('background-color', 'Green');
}
}
});
});
for example as you can see from my code i try to convert the row aData[7] to intiger and put into statement.
"fnRowCallback": function(nRow, aData) {
if (parseInt(aData[7], 10) <= 30) {
$('td', nRow).css('background-color', 'Red');
} else if (parseInt(aData[7], 10) >= 31 && parseInt(aData[7], 10) <= 50) {
$('td', nRow).css('background-color', 'orange');
}
} else if (parseInt(aData[7], 10) >= 31 && parseInt(aData[7], 10) <= 50) {
$('td', nRow).css('background-color', 'orange');
}
Hi everyone sorry for the question, I already solve it.