TypeError: aData is undefined
TypeError: aData is undefined
soulefa
Posts: 1Questions: 1Answers: 0
Hi there ,
I'm using datatable with data from firebase , but i have a TypeError aData is undefined
Here is my code
$.fn.dataTableExt.afnFiltering.push(
function(oSettings, aData, iDataIndex) {
var fromDateG = document.getElementById('fromDate').value;
var toDateG = document.getElementById('toDate').value;
fromDateG = fromDateG.substring(6, 10) + fromDateG.substring(3, 5) + fromDateG.substring(0, 2);
toDateG = toDateG.substring(6, 10) + toDateG.substring(3, 5) + toDateG.substring(0, 2);
var datoffromDateG = aData[6].substring(6, 10) + aData[6].substring(3, 5) + aData[6].substring(0, 2);
var datoftoDateG = aData[7].substring(6, 10) + aData[7].substring(3, 5) + aData[7].substring(0, 2);
if (fromDateG === "" && toDateG === "") {
return true;
} else if (fromDateG <= datoftoDateG && toDateG === "") {
return true;
} else if (toDateG >= datoftoDateG && fromDateG === "") {
return true;
} else if (fromDateG <= datoffromDateG && toDateG >= datoftoDateG) {
return true;
}
return false;
}
);
$(document).ready(function() {
var rootRef = firebase.database().ref().child("users/user3/val");
var table = $('#ex-table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
rootRef.on("child_added", snap => {
var dataSet = [snap.child("temp").val(), snap.child("hum").val(), snap.child("date").val()];
$('#fromDate').change(function() {
table.rows.add([dataSet]).draw();
});
$('#toDate').change(function() {
table.rows.add([dataSet]).draw();
});
});
});
but i have this problem
This discussion has been closed.
Answers
Hi @soulefa ,
It definitely looks defined in there to me! Is the error definitely coming from that filtering function? I tried it here, having your script for the from and to dates, but the core is the same, and it's not showing that error.
Would you be able to do a similar live example that does show the error, please?
Cheers,
Colin