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({
        hiddenColumns: {
          columns: [],
          indicators: true
        }
      })
      for (var j = 0; j < hot.countRows(); j++) {
        for (var i = 0; i < hot.countCols(); i++) {
          if (i === 2 || i === 3) {
            hot.setDataAtCell(j, i, 1)
          }
        }
      }
    }
  })

});