Ho to add class to column dynamically using jQuery datatable

By FoxLearn 2/16/2024 9:23:16 AM   111
This post shows you how to add class to column using jquery datatable.net

jquery datatable add class to td

You can use className to assign a class to the cells in the specified column.

"aoColumnDefs": [
            { "data": "id", "aTargets": [0] },
            {
                "data": "active", "className": "text-center", "aTargets": [1], "mRender": function (data, type, row) {
                    if (data === true)
                        return '<label><input type="checkbox" disabled class="ace-checkbox" checked></label>';
                    else
                        return '<label><input type="checkbox" disabled class="ace-checkbox"></label>';
                }
            }
        ],

You can easily use className to add class to td dynamically using jquery datatable.