No matching records found - dataSrc
No matching records found - dataSrc
brandosha
Posts: 2Questions: 1Answers: 0
Here is my DataTable
code:
var datatable = $('#data_table').DataTable({
processing: true,
serverSide: true,
ajax: {
url: 'processedTableData.php',
data: function(data) {
data.dateRange = $('#date_range_selector').val()
},
dataSrc: function(response) {
for (let i = 0; i < response.data.length; i++) {
var dateStr = response.data[i][4]
dateStr = dateStr.replace(' ', 'T')
dateStr += 'Z'
var date = new Date(dateStr)
response.data[i][4] = date.toLocaleString()
}
console.log(response)
return response
}
},
order: [[4, 'desc']]
})
response
is being logged to the console and all of the data is right, but the table is empty and says
No matching records found
I just don't know what the issue is, it works when I don't put the dataSrc function there.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
It looks like your data is returned in a
data
object. I think you need to return the row data like the third example here:https://datatables.net/reference/option/ajax.dataSrc#Examples
Try
return response.data;
.Kevin
Thank you so much, I can't believe I didn't notice that