Scroller doesn't show results after processing json
Scroller doesn't show results after processing json
Hello,
I've got following datatable code:
var table = $('#table').DataTable({
responsive: true,
colReorder: true,
ajax: {
url: '/some/api',
dataSrc: function ( json ) {
for ( var i=0; i<json.data.length ; i++ ) {
for(var j=0; j <json.data[i].length; j++){
if(json.data[i][j] == "") json.data[i][j] = "NA"
}
}
return json;
}
}
scrollY: 400,
deferRender: true,
scroller: true,
"order": [[0, "desc"]],
columns: [
{data: 0},
{data: 1},
{data: 2},
{data: 3}
]
});
When I add that part:
dataSrc: function ( json ) {
for ( var i=0; i<json.data.length ; i++ ) {
for(var j=0; j <json.data[i].length; j++){
if(json.data[i][j] == "") json.data[i][j] = "NA"
}
}
return json;
}
Datatable doesn't have any records, but when i don't add that it show results but they're not processed.
What's wrong with that code?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Can you link to a test case showing the issue please.
I suspect you need to
return json.data
since theajax.dataSrc
function expects the data array to be returned.Allan
Yes! That was the issue :)
Thanks!