Handsontable example

by handsoncode

HTML

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

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

JavaScript

const container = document.querySelector('#example1');

const hot = new Handsontable(container, {
  data: Handsontable.helper.createSpreadsheetData(5, 5),
  colHeaders: true,
  rowHeaders: true,
  height: 'auto',
  licenseKey: 'non-commercial-and-evaluation',
  dropdownMenu: true
});

Handsontable.hooks.add('modifyColWidth', function(width) {
  if (this === hot.getPlugin('dropdownMenu').menu.hotMenu) {
    return 300;
  }

  return width;
})