create dynamically a datatable (both headers and body data)
create dynamically a datatable (both headers and body data)
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
} );
}
});