Handsontable example

by Jerry Li

HTML

<div id="example1"></div>
<button id="hideColumn">
  Hide column Age
</button>

CSS

</style>

<script src="https://cdn.jsdelivr.net/npm/handsontable@beta/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@beta/dist/handsontable.full.min.css">

JavaScript

var myHeaders = ['Id', 'Name', 'Age'];
  var example = document.getElementById('example1');
  var hot = new Handsontable(example, {
    data: [{
      id: 1,
      profile: {
        name: 'Jerry'
      },
      age: 50
    }, {
      id: 2,
      profile: null,
      age: 60
    },{
      id: 3,
      profile: {
        name: 'Jerry 3'
      },
      age: 70
    }],
    colWidths: 150,
    colHeaders: myHeaders,
    columns: [
      {
        data: function(dataObject) {
          return dataObject.id;
        }
      },
      {
        data: 'name'
      },
      {
        data: 'age'
      }
    ]
  });
  
  const button = document.getElementById('hideColumn');
  button.addEventListener('click', () => {
		hot.selectRows(0, 1);
    hot.render();
  });