JSFiddle - React, Tailwind, and code Playground

by Alagar Kamuthurai

HTML

<div id="example2" class="hot handsontable"></div>

CSS

</style><!-- Ugly Hack due to jsFiddle issue -->

<script src="https://docs.handsontable.com/0.15.1/scripts/jquery.min.js"></script>
<script src="https://docs.handsontable.com/pro/1.4.1/bower_components/handsontable-pro/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/0.15.1/bower_components/handsontable/dist/handsontable.full.min.css">

JavaScript

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

  var
    hiddenData = [
      ['', '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]
    ],
    container = document.getElementById('example2'),
    hot2;
  
  hot2 = new Handsontable(container, {
    data: hiddenData,
    colHeaders: true,
    minSpareRows: 1,
    columns: [
      {data: 0},
      {data: 2},
      {data: 3},
      {data: 4},
      {data: 5},
      {data: 6}
    ],
    columnSummary: [
      {
        destinationRow: 0,
        destinationColumn:1,
        reversedRowCoords: true,
        type: 'sum',
        forceNumeric: true
      }, {
        destinationRow: 0,
        destinationColumn: 2,
        reversedRowCoords: true,
        type: 'sum',
        forceNumeric: true
      }, {
        destinationRow: 0,
        destinationColumn: 3,
        reversedRowCoords: true,
        type: 'sum',
        forceNumeric: true
      }, {
        destinationRow: 0,
        destinationColumn: 4,
        reversedRowCoords: true,
        type: 'sum',
        forceNumeric: true
      }, {
        destinationRow: 0,
        destinationColumn: 5,
        reversedRowCoords: true,
        type: 'sum',
        forceNumeric: true
      }]
  });
  
  function bindDumpButton() {
      if (typeof Handsontable === "undefined") {
        return;
      }
  
      Handsontable.Dom.addEvent(document.body, 'click', function (e) {
  
        var element = e.target || e.srcElement;
  
        if (element.nodeName == "BUTTON" && element.name == 'dump') {
          var name = element.getAttribute('data-dump');
          var instance = element.getAttribute('data-instance');
          var hot = window[instance];
          console.log('data of ' + name, hot.getData());
        }
      });
    }
  bindDumpButton();

});