No matching records found - dataSrc

No matching records found - dataSrc

brandoshabrandosha 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

Answers

This discussion has been closed.