Best way to render boolean data columns in jquery datatables.net
I answered my own question :-) it's actually very simple:
var simple_checkbox = function ( data, type, full, meta ) { var is_checked = data == true ? "checked" : ""; return '<input type="checkbox" class="checkbox" ' + is_checked + ' />';}var setup_datatable = function () { $('#data-table').DataTable({ "columns": [ { "data": "id", "className": "text-center"}, { "data": "keywords"}, { "data": "platform"}, { "data": "is_active", "render": simple_checkbox}, { "data": "is_terminated", "render": simple_checkbox} ], "ajax": "/data" }); // DataTable}
Adding the disabled class will remove the function on the page but keep the look.
var simple_checkbox = function (data, type, full, meta) { var is_checked = data == true ? "checked" : ""; return '<input type="checkbox" **class="checkbox disabled"** ' + is_checked + ' />'; }