Handsontable Basic Example (100x10)
HTML
<script src="https://handsontable.com/bower_components/handsontable/dist/handsontable.full.js"></script>
<link rel="stylesheet" href="https://handsontable.com/bower_components/handsontable/dist/handsontable.full.css">
<div id="example"></div>
CSS
body {
margin: 20px 30px;
font-size: 13px;
font-family: 'Open Sans', Helvetica, Arial;
}
a {
color: #34A9DC;
text-decoration: none;
}
p {
margin: 5px 0 20px;
}
h2 {
margin: 20px 0 0;
font-size: 18px;
font-weight: normal;
}
JavaScript
var data = [
{col0: 0, col1: 1, col2: 'A', desc: 'Letter A', error: true},
{col0: 0, col1: 1, col2: 'B', desc: 'Letter B', error: false},
{col0: 0, col1: 1, col2: 'C', desc: 'Letter C', error: true},
{col0: 0, col1: 1, col2: 'D', desc: 'Letter D', error: false},
]
var columns = [
{
title: "Col 0",
data: 'col0',
readOnly: true,
},
{
title: "Col 1",
data: 'col1',
readOnly: true,
},
{
title: "Col 2",
data: 'col2',
readOnly: true,
renderer: myCustomRender,
},
]
function myCustomRender(instance, td, row, col, prop, value, cellProperties) {
td.title = data[row].desc
td.textContent = value
}
var container = document.getElementById('example');
var hot = new Handsontable(container, {
licenseKey: 'non-commercial-and-evaluation',
data: data,
columns: columns,
rowHeaders: true,
colHeaders: true,
contextMenu: true,
cells: function (row, columns, prop) {
if(data[row].error){
this.valid = false
}
// return this
}
});