Handsontable example

by HYEONGJINKIM

HTML

<div id="example" class="handsontable"></div>

CSS

</style><!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ -->

<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>

<script src="http://handsontable.com/dist/handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="http://handsontable.com/dist/handsontable.full.css">
<link rel="stylesheet" media="screen" href="http://handsontable.com/demo/css/samples.css">
<link rel="stylesheet" media="screen" href="http://handsontable.com/demo/css/samples.css">
<link rel="stylesheet" media="screen" href="http://handsontable.com/demo/css/samples.css">

<style type="text/css">
body {background: white; margin: 20px;}
h2 {margin: 20px 0;}

JavaScript

$(document).ready(function () {

  var
    data = [
      ['접두사', '데이터 타입', '비고(Example)'],
['a', 'Array', 'aUsers'],
['s', 'String', 'sCompanyName'],
['n', 'Number', 'nTotalCount'],
['b', 'Boolean','bFlag, bActivation'],
['o', 'Object',	'oController'],
['ht', 'Hash Table','htUserInfo, htColorCode'],
['d', 'Date',	'dToday, dCurrentTime'],
['el', 'Html Element', 'elTableList'],
['rx', 'Regular Expression',	'rxEmailFormat']
    ],
    container = document.getElementById('example'),
    hot;
  
  hot = new Handsontable(container, {
    data: data,
    minSpareRows: 1,
    colHeaders: true,
    contextMenu: true
  });
  
  
  function bindDumpButton() {
  
      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();

});