2014-12-03 14 views

risposta

19

ho risposto alla mia domanda :-) In realtà è molto semplice:

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 

} 
+2

Questo è fantastico. Penso che dovresti accettare la tua risposta, forse aiuterà le altre persone in futuro. – davidkonrad

2

Aggiunta la classe disabile rimuoverà la funzione sulla pagina, ma mantenere il look.

var simple_checkbox = function (data, type, full, meta) { 
      var is_checked = data == true ? "checked" : ""; 
      return '<input type="checkbox" **class="checkbox disabled"** ' + 
       is_checked + ' />'; 
     } 
+0

Grazie a @eric phillips, questa è una grande idea – Deano

Problemi correlati