Handsontable example

HTML

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

JavaScript

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

  function getData() {
    return [
      ['', 'Kia', 'Nissan', 'Toyota', 'Honda', 'Mazda', 'Ford'],
      ['2012', 10, 11, 12, 13, 15, 16],
      ['2013', 10, 11, 12, 13, 15, 16],
      ['2014', 10, 11, 12, 13, 15, 16],
      ['2015', 10, 11, 12, 13, 15, 16],
      ['2016', 10, 11, 12, 13, 15, 16]
    ];
  }

  var
    example3 = document.getElementById('example3'),
    settings3,
    hot;

  settings3 = {
    data: getData(),
    rowHeaders: true,
    colHeaders: true
  };
  hot = new Handsontable(example3, settings3);

  hot.updateSettings({
    contextMenu: {
      items: {
        "row_above": {
          name: "Row above please",
          disabled: function() {
            // if first row, disable this option
            return hot.getSelectedLast()[0] === 0;
            // does some things after initialization of menu
          },
          callback: function(key, options) {
            hot.alter('insert_row', hot.getSelectedLast()[0])
            // does some things after click
          }
        },
        "custom_item_three": {
          name: "insert failure mode",
          callback: function(key, selection) {
          var end = selection[0].end.row;
          this.alter('insert_row', end + 1)
          }
        },
        "custom_item_six": {
          name: "remove failure mode",
          callback: function(key, selection) {
          	var start = selection[0].start.row;
            var end = selection[0].end.row;
            var amount = end - start + 1;
            console.log(end, start)
            this.alter('remove_row', start, amount);
          }
        }
      }
    }
  })



});