Adding an Index column causes "Requested unknown parameter '0' for row 0, column 0"

Adding an Index column causes "Requested unknown parameter '0' for row 0, column 0"

LegendEffectsLegendEffects Posts: 1Questions: 1Answers: 0

Debugger code (debug.datatables.net): https://debug.datatables.net/eriyer
Error messages shown:
DataTables warning: table id=overTable - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
Description of problem:
I have a section of code which adds an index value to the table, this worked in a previous version of DataTables, I've also read the official guide to adding the index column with the same issue.

I've narrowed it down to calling table.column(0, {page: 'current'}); for the first time causes the error yet it still returns the correct values.

let table = $('#overTable').DataTable({
                language: settings.language,
                processing: true,
                serverSide: true,
                responsive: true,
                ajax: "api/stats",
                columns: [
                    {render: function() {return '';}},
                    {data: settings.headData, render(d) {return '<img src="'+settings.headurl+d+'" class="img-responsive table-head">'}},
                    {data: 'username'},
                    {data: 'kills'},
                    {data: 'deaths'},
                    {data: 'global_elo'},
                    {data: 'username', render(d) {return '<a class="btn btn-primary" href="player/'+d+'">View</a>'}}
                ],
                columnDefs: [
                    {'orderable': false, 'className': 'text-center', 'targets': [0, 1, 6]},
                ],
                order: [[5, 'desc']]
            });
            
            table.on('draw.dt', function () {
                console.log(table.column(0, { page: 'current' }));
                //table.column(0, { page: 'current' }).nodes().each( function (cell, i) {
                //    cell.innerHTML = getTrophy(i + 1 + table.page.info().start);
                //});
            });

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.