Hello,
I have an issue that if I use DataTables Ajax render function for a conditional column it duplicates each row in table.
If I remove the below line then it works fine, but after adding this every row is displayed twice.
{
"data": null,
render: function(data, type, row) {
var disc = row.ispercent == 0 ? row.discount : row.discount+'%';
return disc;
}
},
Please help, thanks in advance.
What I have tried:
$("#classid").change(function(){
var sessionid = $("#sessionid").val();
var classid = $(this).val();
$.ajax({
url : "<?php echo site_url('Ajax/getStuDiscByClassID'); ?>",
method : "POST",
mydata : {sessionid: sessionid, classid: classid},
async : true,
dataType : 'json',
success: function(mydata)
{
$('#example').DataTable({
destroy: true,
data : data,
columns: [
{ data: "id"},
{data: "studentname"},
{ data: 'fathername'},
{
"data": null,
render: function(data, type, row) {
var disc = row.ispercent == 0 ? row.discount : row.discount+'%';
return disc;
}
},
],
dom: 'Blfrtip',
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5',
],
search: true
});
}
});
return false;
});