Requested unknown parameter '0' for row 0, column 0

Requested unknown parameter '0' for row 0, column 0

dowzerdowzer Posts: 11Questions: 3Answers: 0

I am getting the above error on Datatables 1.10.12. The table renders, I can see the columns, I see Showing 1 to 6 of 6 entries and I can see the 6 rows but none of the rows contain anything.

I have looked at TN 4 (https://datatables.net/manual/tech-notes/4) and the first section for Parameter is an integer. There are no colspan etc and I cannot see any issues with the numbers of rows etc.

I did a debug which is at https://debug.datatables.net/edujuj - what am I missing? :/

Answers

  • kthorngrenkthorngren Posts: 21,300Questions: 26Answers: 4,945

    It doesn't look like you used columns.data to define your columns. The data retrieved looks like this:

    {
            "DT_RowId": "row_1",
            "reference": "Client A",
            "depts": "ALL",
            "level": "0",
            "active": "1",
            "actions": "<a href=\"\/edit\/1\" class=\"body_nav\"><i class=\"icon-table-icons icon-pencil\" alt=\"Edit\" title=\"Edit\"><\/i><\/a><a href=\"\/del\/1\" class=\"body_nav\" onClick=\"return confirm('Are you sure?')\"><i class=\"icon-table-icons icon-cancel-circle\" alt=\"Delete\" title=\"Delete\"><\/i><\/a>"
        }
    

    You are receiving an array of objects as described here:
    https://datatables.net/manual/data/#Data-source-types

    You will need to define your columns, for example:

        columns: [
            { data: 'reference' },
            { data: 'depts' },
            { data: 'level' },
            { data: 'active' },
            { data: 'actions' },
        ],
    

    Kevin

  • dowzerdowzer Posts: 11Questions: 3Answers: 0

    Thanks for the reply - I have added in the columns:

    I have a variable called colname which contains:

        var colname = ["reference","depts","level","active","actions"];
        var colnum = 0;
    

    And then I am looping through them later on - I am using column filters and they populate fine with the actual values but the table itself does not

  • kthorngrenkthorngren Posts: 21,300Questions: 26Answers: 4,945

    The tech note mentions this:

    When {parameter} is an integer, DataTables is looking for data from an array.

    Like I mentioned before your data structure is using objects not arrays. Did you try as I suggested?

    Kevin

This discussion has been closed.