I tried displaying data into datatables with ajax source json, before there was no problem but after I found the nested json array I was a little confused to implement it, so how do I apply the json I have into datatables . this is my data
Config datatables
var myTable = $('#myTable').DataTable({
ajax: base_url+"api/data/list",
responsive: true,
columns: [
{ "data": "", "sClass": "text-center", responsivePriority: 0 },
{ "data": "first_name", "sClass": "text-center", responsivePriority: 1 },
{ "data": "last_name", "sClass": "text-left"},
{ "data": "birth_date", "sClass": "text-left", responsivePriority: 2 },
{ "data": "birth_place", "sClass": "text-left" },
],
language: {
searchPlaceholder: 'Search...',
sSearch: '',
zeroRecords: 'No data',
}
})
Result ajax json
{
"data": [
{
"1": {
"first_name": "Jonh",
"last_name": "Connor",
"birth_date": "1991-11-05",
"birth_place": "USA"
},
"2": {
"first_name": "Uka",
"last_name": "Uka",
"birth_date": "2013-01-06",
"birth_place": "Austria"
}
}
]
}
which I expect the result as the following table
| NO | first_name | last_name | birth_date | birth_place |
| 1 | Jonh | Connor | 1991-11-05 | USA |
| 2 | Uka | Uka | 2013-01-06 | Austria |