Handsontable example

by handsoncode

HTML

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable-pro@5.0.0/dist/handsontable.full.min.css">
<script src="https://cdn.jsdelivr.net/npm/handsontable-pro@5.0.0/dist/handsontable.full.min.js"></script>
<div id="example1" class="hot handsontable htRowHeaders htColumnHeaders ht__manualColumnMove"></div>

JavaScript

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

  var
    myData = Handsontable.helper.createSpreadsheetData(100, 26),
    container = document.getElementById('example1'),
    hot;

  hot = new Handsontable(container, {
    data: myData,
    rowHeaders: true,
    colHeaders: true,
    colWidths: 100,
    contextMenu: true,
    manualColumnFreeze: true
  });

  hot.updateSettings({
    contextMenu: {
      items: {
        "option": {
          name: 'custom value',
          callback: function(key, options) {
            var val = hot.getDataAtCell(hot.getSelectedLast()[0], hot.getSelectedLast()[1])
            alert(val);
            window.open('http://google.com/?' + val, '_blank');
          },
        }
      }
    }
  })


});