0
votes

I am facing an issue in jquery datatable i.e "DataTables warning: table id=paginatedTable - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4"

my.js

$(document).ready(function() {
    $('#paginatedTable').DataTable({
        "processing" : false,
        "serverSide" : true,
        "pageLength" : 1,
        ajax : {
            url : 'myurl',
             "contentType": "application/json; charset=utf-8",
             "dataType": "json", 
            dataFilter : function(data) {

                return data; 
            },
            "columns" : [ {
                "data" : "orderId",sDefaultContent: "n/a"
            }, {
                "data" : "customer",sDefaultContent: "n/a"
            }, {
                "data" : "amount" ,sDefaultContent: "n/a"
            }, {
                "data" : "date", sDefaultContent: "n/a"
            }, {
                "data" : "status",sDefaultContent: "n/a"
            }, {
                "data" : "paymentModule",sDefaultContent: "n/a"
            } ]
        }
    });
});

Data.json

{
    "draw": "1",
    "recordsFiltered": "2",
    "recordsTotal": "2",
    "data": [
        {
            "orderId": "2",
            "customer": "Rehan Afridi",
            "amount": "887",
            "date": "2018-06-22",
            "status": "DELIVERED",
            "paymentModule": "moneyorder"
        },
        {
            "orderId": "1",
            "customer": "aD SDAFASD",
            "amount": "887",
            "date": "2018-06-22",
            "status": "ORDERED",
            "paymentModule": "moneyorder"
        }
    ]
}
1

1 Answers

0
votes

Check the link to the error https://datatables.net/manual/tech-notes/4. Check your '#paginatedTable' table structure.

Reading this error documentation I think your error can have two reasons:

There is a colspan or rowspan in the tbody of the table, which is not supported by DataTables.

or

Using columns or columnDefs you have specified more columns than there are in the HTML.