A Pen by Jaime Gaspar on CodePen.
Created
March 31, 2019 17:04
-
-
Save jegazhu/1c98c0e3e183ab9a2a8181dc3afd554b to your computer and use it in GitHub Desktop.
Excel-Like example with Handsontable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Excel-Like example with <b>Handsontable</b></h1> | |
<p>Easy sample of how to use <a href="https://handsontable.com/index.html">Handsontable</a>, a minimalist Excel-like data grid editor for HTML & JavaScript. | |
</p> | |
<div id="grid" class="handsontable"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
var data = [ | |
['', 'Maserati', 'Mazda', 'Mercedes', 'Mini', 'Mitsubishi'], | |
['2009', 0, 2941, 4303, 354, 5814], | |
['2010', 5, 2905, 2867, 412, 5284], | |
['2011', 4, 2517, 4822, 552, 6127], | |
['2012', 2, 2422, 5399, 776, 4151] | |
]; | |
var container = document.getElementById('grid'), | |
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]; | |
} | |
}); | |
})(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src="https://handsontable.com/dist/handsontable.full.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background: #f3f3f3; | |
margin: 20px; | |
color: #3d3d3d; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://handsontable.com/dist/handsontable.full.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment