Cannot see json in my datatable
Cannot see json in my datatable
Hello everyone,
I create a json object ,
{"devices":[{"name":"D9123","id":"32","isOn":"true","automation":{"suspended":"true","expiration":"15 January 20:00pm 2020"}},{"name":"D9043","id":"45","isOn":"true","automation":{"suspended":"false"}},{"name":"D4120","id":"29","isOn":"false","automation":{"suspended":"false"}}]}
and i am working on ajax i want to create a datable which has this elements but i cannot see objects in it.
This is my table:
Devices | Status | Automation |
---|
@section scripts
{
<script>
$(document).ready(function () {
$('#table').DataTable(
{
"ajax": {
"url": 'myurl',
"type": 'GET',
"datatype": 'json',
"dataSrc" : "data"
},
columns: [
{ "devices": 'name' },
{ "devices": 'isOn' },
{ "devices": 'automation.suspended' }
]
});
});
</script>
}
what is the problem please help me
This question has an accepted answers - jump to answer
Answers
Looks like you need to change your
ajax.dataSrc
option from"dataSrc" : "data"
to"dataSrc" : "devices"
.Kevin
I change it but it is not work also it give me an error in a popup,
DataTables warning: table id=table - Requested unknown parameter '0' for row 0, column 0.
I solve the problem i just make this changes,
aoColumns: [