varying column number error

varying column number error

starflystarfly Posts: 1Questions: 1Answers: 0

I have a varying amount of columns for each run. It seems that the below example works if i hardcode everything.

var data_array =[{'data': 'detail1'}, {data: 'detail2'}, {data: 'detail3'},

$('#example').DataTable( {
ajax: {
url: api_url,
},
columns:data_array});
});

However if i would to do something like this, it does not work at all. I get something like this from the start jquery.dataTables.min.js:66 Uncaught TypeError: Cannot read property 'aDataSort' of undefined.
var data_array = []
for(var i = 0; i < 10; i++){
data_array.push({'data': "detail"+ i.toString()})
}

Answers

  • allanallan Posts: 61,920Questions: 1Answers: 10,153 Site admin

    Can you show us the full code you are using please, ideally with a link to a test case as requested in the forum rules.

    Allan

This discussion has been closed.