I'm trying to load a table using the datatables component.
The return of this ajax request is a json object in this format:
data = {
"CLIENTES": {
"0": {
"ID": "1",
"NOME": 'GABRIEL'
},
"1": {
"ID": "2",
"NOME": 'RODRIGUES'
}
}
}
In the documentation columns data it is mentioned that the following structure should be created:
table.DataTable({
"ajax": url,
columns: [
{"data": "CLIENTES.ID"},
{"data": "CLIENTES.NOME"}
]
});
But access to indexes is not done correctly, in this case they should be accessed:
{"data": "CLIENTES['0'].ID"},
{"data": "CLIENTES['1'].ID"},
Dynamically, how could I do this?
There is a related question that also did not solve my question: Load table with json using datatables