Handsontable example

HTML

<link rel="stylesheet" href="https://docs.handsontable.com/pro/1.14.2/bower_components/handsontable-pro/dist/handsontable.full.min.css">
<script src="https://docs.handsontable.com/pro/1.14.2/bower_components/handsontable-pro/dist/handsontable.full.min.js"></script>
<input type="checkbox" class="hide"> Hide columns
<div id="example1" class="hot handsontable htColumnHeaders"></div>

CSS

.pink {
  color: pink;
}

JavaScript

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

  var
    container = document.getElementById('example1'),
    hot;

  var data = [
    ['John', 'Smith', '49', 'Teacher'],
    ['Micheal', 'Adams', '33', 'Programmer'],
    ['Tony', 'Quierra', '19', 'Student'],
    ['John', 'Smith', '49', 'Teacher'],
    ['Micheal', 'Adams', '33', 'Programmer'],
    ['Tony', 'Quierra', '19', 'Student'],
    ['John', 'Smith', '49', 'Teacher'],
    ['Micheal', 'Adams', '33', 'Programmer'],
    ['Tony', 'Quierra', '19', 'Student'],
    ['John', 'Smith', '49', 'Teacher'],
    ['Micheal', 'Adams', '33', 'Programmer'],
    ['Tony', 'Quierra', '19', 'Student'],
    ['John', 'Smith', '49', 'Teacher'],
    ['Micheal', 'Adams', '33', 'Programmer'],
    ['Tony', 'Quierra', '19', 'Student'],
    ['John', 'Smith', '49', 'Teacher'],
    ['Micheal', 'Adams', '33', 'Programmer'],
    ['Tony', 'Quierra', '19', 'Student']
  ];

  hot = new Handsontable(container, {
    data: data,
    colWidths: 100,
    colHeaders: ['Name', 'Surname', 'Age', 'Job title']
  });

  var hide = document.querySelector('.hide');
  hide.addEventListener('change', function() {
    if (hide.checked) {
      hot.updateSettings({
        hiddenColumns: {
          columns: [2, 3],
          indicators: true
        }
      })
    } else {
      hot.updateSettings({
        renderer: myRenderer,
        hiddenColumns: {
          columns: [],
          indicators: true
        }
      })
    }
  })


  function myRenderer(instance, td, row, col, prop, value, cellProperties) {
    Handsontable.renderers.TextRenderer.apply(this, arguments);
    if (col === 2 || col === 3) {
      td.innerHTML = 1
    }

    return td;
  }

});