Array of arrays
HTML
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="//cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<table id="reservations" >
<thead>
<tr>
<th>ID</th>
<th>User</th>
<th>Open Date</th>
<th>Ticket Status</th>
<th>End Date</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
CSS
div {
margin: 5px;
}
table {
border: 2px solid black;
}
td {
padding: 10px;
border: 1px solid lightgrey;
}
JavaScript
var reservations = [[{'id': 1021972,'Aging_Un_investigated_Issue': '0.94',
'User': 'John P.', 'Open_date':'2017-08-04 01:34:18','End_date':'2017-09-05 00:29:01',
'Ticket_status':'Transferred'},{'id': 1036722, 'Aging_Un_investigated_Issue': '0.01',
'User': 'John P.', 'Open_date':'2017-09-01 00:34:18',
'End_date':'', 'Ticket_status':'Researching'},{'id': 1015621,
'Aging_Un_investigated_Issue': '0.11', 'User': 'John D.','Open_date':'2017-01-01 00:00:18',
'End_date':'2017-09-01 20:20:57','Ticket_status':'Closed'}],
[{}],
[{}],
[{'id': 1045971,'Aging_Un_investigated_Issue': '0.23',
'User': 'John C.', 'Open_date':'2016-05-01 02:32:18','End_date':'2017-09-05 12:29:01',
'Ticket_status':'Transferred'},{'id': 1035522, 'Aging_Un_investigated_Issue': '0.02',
'User': 'John C.', 'Open_date':'2015-08-01 00:34:18',
'End_date':'', 'Ticket_status':'Researching'},{'id': 1223621,
'Aging_Un_investigated_Issue': '0.11', 'User': 'John C.','Open_date':'2016-01-01 00:00:18',
'End_date':'2017-09-02 21:20:57','Ticket_status':'Closed'}]];
var tbody = $('#reservations tbody'),
props = ["id", "User", "Open_date", "Ticket_status", "End_date"];
$(reservations)
.map((i, reservation) => reservation) // "Flatten" your list to make it easier to work with.
.filter((i, reservation) => Boolean(reservation.id)) // Remove all items which do not have an `id`
.each(function(i, reservation) {
var tr = $('<tr>');
$.each(props, function(i, prop) {
$('<td>').html(reservation[prop]).appendTo(tr);
});
tbody.append(tr);
});
$(document).ready(function(){
$('#reservations').DataTable();
});