TypeError: n is undefined when trying to sort datatable datetime coloum
TypeError: n is undefined when trying to sort datatable datetime coloum
Hi..
I have a column with mysql datetime..whenever am trying to sort , in console its saying.. TypeError: n is undefined.
dataTables/1.10.7/css/jquery.dataTables.min.css
jquery/1.9.1/jquery.min.js
jquery/plugins/dataTables/1.10.7/js/jquery.dataTables.min.js
My json data:-
{'id': 524, 'site': 'lab14', 'devicetype': 'ios', 'hostname': 'lab14-co-acc-rsw1xser3', 'status': 'COMPLETED', 'username': 'Sunderdebast', '****stage_date': '2020-04-18 13:17:48****', 'model': 'C9410R', 'deployment_id': '40a9b37b-e771-44d4-86db-bc304e0c0d09', 'download_url': 'https://**.com/40a9b37b-e771-44d4-86dbsss-bc304e0c0d09/lab14-co-acc-rxwc/lab14-co-acc-rsw1x823.log'}]
Am using vanilla JS ajax request to dynamically add rows to a table and then initiate
$(document).ready(function() {
$.fn.dataTable.ext.errMode = 'none';
$('#History').DataTable();
} );
Evertthing works except sorting on datetime.
2020-04-14 09:47:37 ---> This is how i am getting in the datatable.
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
// Get the staging history data from Database and populate in UI
document.getElementById("History staging").addEventListener('click', gethistory)
function gethistory(){
const req = new XMLHttpRequest();
req.open('POST', '/gethistory/', true);
req.setRequestHeader('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
// send Post body ( osveriosn, model and modeltype )
req.send()
req.onreadystatechange = function () {
// if backend process is sucess then change the content
if(req.readyState === XMLHttpRequest.DONE && req.status === 200) {
}
}
I guess. may be the datatable is actually getting initiated before table gets filled since its async request.
Please link to a test case as I requested above, it will make debugging possible for us
Colin