I’m having a little issue with my DataTable ( DataTables.js ). I’m trying to get some images from a PHP function by an AJAX call.
I want to call the function only for the current page, not for the whole table. I tried placing “deferRender: true” inside “DataTable” and inside “columnDefs”, but is not working. It’s still called for the whole table
Code:
$('#CategoriProductsTable').DataTable( {
data: data, // Getting all the data
deferRender: true, // Useless
columnDefs: [
{
targets: 0,
"data": function (data, type, dataToSet) { // This function I want to call it only for the current page, not for the entier table.
$.ajax({
url: "/core/pagination/produse.pagination.php",
type: "post",
data: {
GetArticleImage: "Yes",
ArticleID: data.part_number,
SupplierID: data.supplier_id,
SupplierName: data.supplier_name
},
}).done(function (data) {
return data;
//$(currentCell).html(data);
});
//return '<img class="manufacturers-logo" src="/resources/assets/images/logos/'+data.supplier_id+'.jpg" alt="'+data.supplier_name+'">'+data.supplier_name;
}
},
// IGNORE FROM HERE
{
"targets": [ 1 ],
"data": "supplier_name"
// Merge
//"data": function (data, type, dataToSet) {
// return '<img class="manufacturers-logo" src="/resources/assets/images/logos/'+data.supplier_id+'.jpg" alt="'+data.supplier_name+'">'+data.supplier_name;
// }
},
{
"targets": [ 2 ],
"data": "part_number"
}
]
} );