G'day,
I've been using DataTables successfully in a number of projects, thank you for such a useful tool. Currently I'm trying to use the datetime-moment plugin with a dynamically created table, and I just cannot get it to work :(
I define the moments using the date format in use:
$.fn.dataTable.moment("DD-MMM-YYYY HH:mm:ss.SSS Z");//01-Mar-2018 08:51:55.481 +11:00
However, I construct the table behind the scenes from json data, and then append the dynamic table to a placeholder div:
<div id="tableDiv" style="width:100%"></div>
$("#tableDiv").append('<table id="jobsTable" class="table table-striped dataTable-font" cellspacing="0" style="width:100%"><thead><tr>' + tableHeaders + '</tr></thead></table>');
$("#jobsTable").DataTable({
"autoWidth": true,
"data": result.attached_data.jobs, //json object containing data
"columns": columns, //columns array
"scrollY": 400,
"scrollX": true,
"destroy": true,
"language": {
"search": "Filter results: "
},
});
The data displays fine in the table, I can select rows, perform actions on the data, etc but cannot get the date columns to sort as intended.
Any pointers will be greatly appreciated!