create dynamically a datatable (both headers and body data)

create dynamically a datatable (both headers and body data)

goannagoanna Posts: 4Questions: 1Answers: 0
edited September 2014 in Free community support

Hello,

I need help as fast as it is possible!

I want to create a datatable dynamically, but my implementation doesn't work!

Here is my code:

$('#view-panel').html( '

' );

$.ajax({
"url": "/command/core/get-columns",
"data": {
"project": id
},
"type": "GET",
"success": function(result) {
var columnHeaders = [];
for(var i=0; i<result.length; i++) {
columnHeaders.push({
"title": result[i],
"defaultContent": "null"
});
}
$('#example').dataTable( {
"processing": true,
"serverSide": true,
"ordering": false,
"searching": false,
"ajax": {
"url": "/command/core/get-records",
"data": {
"project": id
},
"type": "POST"
},
"columns": columnHeaders
} );
}
});

This discussion has been closed.