Handsontable example

HTML

<div id="example1" class="hot handsontable htColumnHeaders"></div>

CSS

</style>< !-- Ugly Hack due to jsFiddle issue --><script src="https://docs.handsontable.com/pro/1.18.0/bower_components/handsontable-pro/dist/handsontable.full.min.js"></script><link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/pro/1.18.0/bower_components/handsontable-pro/dist/handsontable.full.min.css">

JavaScript

document.addEventListener("DOMContentLoaded", function() {

  function getCarData() {
    return [{
        car: "Mercedes A 160",
        year: 2017,
        available: 1,
        comesInBlack: 'yes'
      },
      {
        car: "Citroen C4 Coupe",
        year: 2018,
        available: 0,
        comesInBlack: 'yes'
      },
      {
        car: "Audi A4 Avant",
        year: 2019,
        available: 1,
        comesInBlack: 'no'
      },
      {
        car: "Opel Astra",
        year: 2020,
        available: 0,
        comesInBlack: 'yes'
      },
      {
        car: "BMW 320i Coupe",
        year: 2021,
        available: 0,
        comesInBlack: 'no'
      }
    ];
  }

  var example1 = document.getElementById('example1'),
    hot1;


  (function(Handsontable){
     function chx(instance, td, row, col, prop, value, cellProperties) {
       Handsontable.renderers.CheckboxRenderer.apply(this, arguments);
       td.style.fontWeight = 'bold';
       td.style.color = 'green';
       td.style.background = '#CEC';
     }

     // Register an alias
     Handsontable.cellTypes.registerCellType('checkbox', {
       renderer: chx
     });
 
    })(Handsontable);

  hot1 = new Handsontable(example1, {
    data: getCarData(),
    colHeaders: ['Car model', 'Year of manufacture', 'Available'],
    columns: [{
        data: 'car'
      },
      {
        data: 'year',
        type: 'numeric'
      },
      {
        data: 'available',
        type: 'checkbox',
        checkedTemplate: 1,
        uncheckedTemplate: 0
      }
    ]
  });

});