render function is called twice with type === 'display' for each cell
render function is called twice with type === 'display' for each cell
Hello DataTables team,
I've noticed strange behavior and can't find its reason. When I initialise a DataTable instance, which gets data via AJAX, like the following:
settings_table = $('#settings_table').DataTable({
paging: false,
searching: false,
info: false,
order: [[1, 'asc']],
columnDefs: [
{ orderable: false, targets: 0 },
],
ajax: {
url: '/settings.json'
},
columns: [
{ data: 'account' },
{ data: 'country' },
{ data: function (row, type, val, meta) {
console.log(row);
console.log(type);
if(type === 'display') {
return "test";
}
return row;
} }
]
});
I see that function for third column (index 2) is called 3 times for every cell. First time it's called with type === 'display', second time — with type === 'type' and third time — with type === 'display'. I can't figure out, why it needs to execute the same function twice with 'display' type. Can you please explain?
I ask this because I want to generate HTML snippet for specific cells and want to avoid unnecessary processing. I use DataTables v.1.10.9
Could you please also advise, how to maximize rendering performance by caching cell's content. I tried to use columnDefs -> data: function for type === 'set', but didn't get it executed.
Thank you!