js in order to display a json file. I extract the name of my columns and build an array like this one :
columns = ["Date", "C2R", "CM", "Total"]
My sTitle and mData have the same name so I try to do that but fail.
jQuery('#result_example').dataTable( {
"data": result_table,
"columns": [
jQuery.each(columns, function(i, value){
//console.log(value); which give ["Date", "C2R", "CM", "Total"]
{ "sTitle": + value + , "mData": + value + },
})
],
paging: true,
searching: false,
"bInfo" : false
} );
The objective is to have a result like this :
jQuery('#result_example').dataTable( {
"data": result_table,
"columns": [
{ "sTitle": "Date" , "mData": "Date" },
{ "sTitle": "C2R" , "mData": "C2R" },
{ "sTitle": "CM" , "mData": "CM" },
{ "sTitle": "Total" , "mData": "Total" }
],
paging: true,
searching: false,
"bInfo" : false
} );