This is my ajax datatable. Now I can get the values on data table, and assigned the value is null when there isn't any matching condition. But What I need is, Have to hide the rows where there isn't any data or null value. If I remove the else condition getting an error as "requesting unknown parameter on column 0 row1..."
$('#retail-modal-retail-price-history').DataTable({
data: record.retail_history,
destroy: true,
searching: false,
ordering: false,
dom: '<<"row"<"col">>t<"row"<"col">>>',
columns: [
{
data: "price",
'render': function (data, type, row, meta){
if(row.TYPE==='re'){
return data/100;
}
else
return null;
}
},
{
data: "scheduled_from",
'render': function (data, type, row, meta){
if(row.TYPE==='re'){
return data;
}
else
return null;
}
},
],
});
Want to hide the row which is coming at last. I can be able to achieve it by simply calling the below function.
$('#retail-modal-retail-price-history tr').each(function() {
if ($(this).find('td:empty').length) $(this).remove();
});
But I understand, this is not a good solution. If there are any optimized way to do it