Handsontable example

HTML

<div id="example3" class="hot handsontable htRowHeaders htColumnHeaders"></div>

CSS

</style><!-- Ugly Hack due to jsFiddle issue --> <script src="https://docs.handsontable.com/bower_components/handsontable/dist/handsontable.full.js"></script> <link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/bower_components/handsontable/dist/handsontable.full.min.css">

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,
    hot3;

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

  hot3.updateSettings({
    contextMenu: {
      callback: function(key, options) {
        if (key === 'about') {
          setTimeout(function() {
            // timeout is used to make sure the menu collapsed before alert is shown
            alert("This is a context menu with default and custom options mixed");
          }, 100);
        }
      },
      items: {
        "testsubmenu1": {
          key: "Pick a header color",
          name: "submenu",
          "submenu": {
            "items": [{
              key: "submenu:1",
              "name": "Red",
              callback: function(key, options) {
                //replace the styles
              }
            }, {
              key: "submenu:2",
              "name": "Orange",
              callback: function(key, options) {
                //replace the styles
              }
            }, {
              key: "submenu:3",
              "name": "Yellow",
              callback: function(key, options) {
                //replace the styles
              }
            }]
          }
        }
      }
    }
  })


});