jQuery DataTables Checkboxes: Disable checkboxes on page load

For more information, see https://www.gyrocode.com/projects/jquery-datatables-checkboxes/

by gyrocode

HTML

<link rel="stylesheet" href="https://cdn.datatables.net/w/dt/dt-1.10.18/sl-1.3.0/datatables.min.css">
<script src="https://cdn.datatables.net/w/dt/dt-1.10.18/sl-1.3.0/datatables.min.js"></script>
<script src="https://gyrocode.github.io/jquery-datatables-checkboxes/1.2.11/js/dataTables.checkboxes.min.js"></script>
<link rel="stylesheet" href="https://gyrocode.github.io/jquery-datatables-checkboxes/1.2.11/css/dataTables.checkboxes.css">
<h3><a href="https://www.gyrocode.com/projects/jquery-datatables-checkboxes/">jQuery DataTables Checkboxes</a>: <a target="_blank" href="https://www.gyrocode.com/projects/jquery-datatables-checkboxes/examples/api/">API</a> - <a target="_blank" href="https://www.gyrocode.com/projects/jquery-datatables-checkboxes/examples/api/disable-checkboxes/">Disable checkboxes on page load</a></h3>
    
<table id="example" class="display" cellspacing="0" width="100%">
   <thead>
      <tr>
         <th></th>
         <th>Name</th>
         <th>Position</th>
         <th>Office</th>
         <th>Extn</th>
         <th>Start date</th>
         <th>Salary</th>
      </tr>
   </thead>
   <tfoot>
      <tr>
         <th></th>
         <th>Name</th>
         <th>Position</th>
         <th>Office</th>
         <th>Age</th>
         <th>Start date</th>
         <th>Salary</th>
      </tr>
   </tfoot>
</table>

<hr><a target="_blank" href="https://www.gyrocode.com/projects/jquery-datatables-checkboxes/examples/basic/basic-initialization/">See full article on Gyrocode.com</a>

JavaScript

$(document).ready(function() {
   var table = $('#example').DataTable({
      'ajax': 'https://gyrocode.github.io/files/jquery-datatables/arrays_id.json',
      'columnDefs': [
         {
            'targets': 0,
            'render': function(data, type, row, meta){
               data = '<input type="checkbox" class="dt-checkboxes">'
               if(row[2] === 'Software Engineer'){
                  data = '';
               }
               
               return data;
            },
            'createdCell':  function (td, cellData, rowData, row, col){
               if(rowData[2] === 'Software Engineer'){
                  this.api().cell(td).checkboxes.disable();
               }
            },            
            'checkboxes': {
               'selectRow': true
            }
         },
      ],
      'select': {
         'style': 'multi'
      },      
      'order': [[1, 'asc']]
   });
});