Upgrading from 1.10 to 2.0.3, question about columns render not bound to data

Upgrading from 1.10 to 2.0.3, question about columns render not bound to data

3pwq13pwq1 Posts: 2Questions: 1Answers: 0

Hello. I am upgrading DataTables from 1.10 to 2.0.3. I currently render buttons in an extra column not tied to any data.

columns: [
            {
                data: "data1",
                orderable: true,
            },
            {
                data: "data2",
                orderable: true,
            },
            {
                data: "data3",
                orderable: true,
            },
            {
                orderable: false,
                render: function (data, type, row, meta) {
                    return (
                        '<a class="btn-link table-link" href="/edit/' 
                        "/" +
                        row.id +
                        '"><i class="fal fa-pencil-alt"></i>Edit</a>'
                    );
                },
            },

This code no longer works and throws a client side error in the console:

Uncaught Error: DataTables warning: table id=data-table - Requested unknown parameter '3' for row 0, column 3.

I can get this error to go away by adding a 'data: "data1"' value to the last column that doesn't get used, but is that the recommended way to handle this use case, or is there a more standard/better way to do it in DataTables v2?

This question has an accepted answers - jump to answer

Answers

Sign In or Register to comment.