"Requested unknown parameter '3' for row 0"

"Requested unknown parameter '3' for row 0"

goodideadavegoodideadave Posts: 12Questions: 2Answers: 0

I'm getting this error when loading data. The table is defined as having three columns, but dataTables is adding a 4th column, with no header and with "null" in each cell of the fourth column. The docs say I am defining an extra column in my table, but not in my ajax dataset.

The table is defined like so:

<table id="tblPayPeriodTotals" class="table display table-condensed">
                <thead>
                    <tr>
                        <th>Company ID</th>
                        <th>Pay Period</th>
                        <th>Total Amount</th>
                    </tr>
                </thead>
                <tbody>                
                </tbody>
            </table>

The table is defined in js like so:

table = $("table#tblPayPeriodTotals:first").DataTable({
            "processing": true,
            "autoWidth": false,
            "ordering": false, 
            "dom": 'rt',    // only show the processing (r) & table (t) elements
            "columns": [
               //Assign the data to rows
                { "data": "CompanyID" },
                { "data": "PayPeriod" },
                { "data": "TotalAmount" },
            ],
            "columnDefs": [
                { "targets": 0, "width": "60px" },
                { "targets": 1, "width": "60px" },
                { "targets": 2, "width": "140px" }
            ]
        });

and the data is an object array:

var companyData = {};

Any idea what I'm doing wrong?

This question has an accepted answers - jump to answer

Answers

  • goodideadavegoodideadave Posts: 12Questions: 2Answers: 0

    Also, I'm in IE8 (corporate standard) with DataTables 1.10.2.

    Just tested it with Chrome 39.0.2171.71, and it works as expected.

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394
    Answer ✓

    Only a guess:

         { "data": "TotalAmount" },
    

    that's the last element in the "columns" array, so the trailing comma is redundant. Maybe it's suggesting a fourth (non-existent) element?

  • goodideadavegoodideadave Posts: 12Questions: 2Answers: 0

    Aaargh, thank you tangerine. That was it.

This discussion has been closed.