Brand new to DataTables - DataTables warning: table id=lenderTable - Requested unknown parameter '5'

Brand new to DataTables - DataTables warning: table id=lenderTable - Requested unknown parameter '5'

ryans4595ryans4595 Posts: 4Questions: 1Answers: 0

I have new ASP.NET Core 5 MVC app that I am adding DataTables to.
I have a controller method is that called via the ajax in the DataTable and returns json.
Here is my javascript I wrote:

$(document).ready(function () {
        $('#lenderTable').dataTable({
            "processing": true, // for show progress bar
            "serverSide": true, // for process server side
            "filter": true, // this is for disable filter (search box)
            "orderMulti": false, // for disable multiple column at once
            "ajax": {
                "url": "/Admin/GetLenders",
                "type": "POST",
                "datatype": "json"
            },
            "columnDefs": [{
                "targets": [0],
                "visible": false,
                "searchable": false
            }],
            "columns": [
                { "data": "id" },
                { "data": "lenderName" },
                { "data": "lenderCode" },
                { "data": "modifiedOn" },
                { "data": "status" },
                {
                    "render": function (data, type, row, meta) { return '<a class="btn btn-info" href="/Lender/Edit/' + row.id + '">Edit</a>'; }
                },
                {
                    data: null,
                    render: function (data, type, row) {
                        return "<a href='#' class='btn btn-danger' onclick=DeleteData('" + row.id + "'); >Delete</a>";
                    }
                },
            ]

        });
    });

I get the full error of:
DataTables warning: table id=lenderTable - Requested unknown parameter '5' for row 0, column 5.

All of the data otherwise gets loaded correctly despite the error.

I have looked the documentation and I dont understand what the problem is.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946
    Answer ✓

    Try adding data: null to the column with the edit button, like the delete button column.

    Kevin

  • ryans4595ryans4595 Posts: 4Questions: 1Answers: 0

    Thank you Kevin for the quick help. I fixed it and it is working great

Sign In or Register to comment.