1

I have my data as json key value pairs in an array.

$(document).ready(function () {
        var table = $("#main").DataTable({
            columns: [{
                    "data": "ProductNumber",
                    "title": "ProductNumber"
                },
                {
                    "data": "ReceivingDate",
                    "title": "ReceivingDate"
                }]

I want to add checkboxes so that users can select some rows.

columnDefs: [{
                targets: 0,
                searchable: false,
                orderable: false,
                className: 'dt-body-center',
                render: function (data, type, full, meta) {
                    return '<input type="checkbox" name="id[]" value="' +
                        $('<div/>').text(data).html() + '">';
                }
            }]

I found the columnDef example from the DataTable website. The issue is, it is told to render this checkbox on column 0 which replaces my productnumber column. And I can't add an empty column as my json data has the exact number of data as the columns have. Are there any other ways I can achieve this?

1 Answer 1

-1

You can insert the checkbox into an existing cell like Id Columns.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.