I'm looking to customize the appearance of my datatable columns, like this :
However, when I try to implement it, the datatable displays a message saying "No data available in table". Here's my current code:
$(function() {
$('#Spécialité').DataTable(
{
"ajax": {
"processing": false,
"url": "show_spe",
"type": "GET",
"datatype":'json',
"async": 'true',
success: function(resp) {
let string = JSON.stringify(resp);
let obj = JSON.parse(string);
$.each( obj, function( key, value )
{
$('#Spécialité').append('<tbody><tr><td>'+obj[key]["id"]+'</td> <td>'+obj[key]["description"]+'</td><td><button type="button" class="btn btn-warning" id="edit'+obj[key]["id"]+'">Editer</button> <button type="button" class="btn btn-danger" id="edit'+obj[key]["id"]+'">Supprimer</button></td></tr></tbody>');
});
},
},
} );
Here is a snippet of my json data:
0 {
id : "0"
description : "test" }
1 {
id : "1"
description : "ligne2" }
Appreciate any assistance. Regards :)