Why is column().data() returning an array of dashes? ["-", "-", "-"]
Why is column().data() returning an array of dashes? ["-", "-", "-"]
subasically
Posts: 3Questions: 1Answers: 0
I have a table that is loading data with an ajax call, I am using dataSrc to manipulate the data before rendering it.
var opportunitiesTable = $('#opportunityList').DataTable({
initComplete: function( settings, json ) {
// Table loaded! Show what is in column 3
console.log(this.api().column(3).data());
},
ajax: {
url: "/ajax/opportunity/GetOpportunitiesByNetwork",
dataSrc: function(res) {
//console.log(res);
if (typeof (res) === "object" && res.ResponseCode === 200) {
opportunityData = res.Data;
return opportunityData;
} else {
// Else show API error message
}
}
}
});
What gets console logged
["-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", …]
Table renders correctly though...
This discussion has been closed.
Answers
Without being able to see your data its hard to say what the problem is. For help with troubleshooting please post a link to your page or a test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I tried to replicate my page on this JSFiddle. My local page does not show the alert error that the JSFiddle example does but the data is a sample of the data I am loading locally.
In the JSFiddle example when I console log the column data it returns an array of nulls.