InputMaxLength
HTML
<html>
<head>
<script src="https://bossanova.uk/jexcel/v4/jexcel.js"></script>
<script src="https://bossanova.uk/jsuites/v2/jsuites.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v2/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://bossanova.uk/jexcel/v4/jexcel.css" type="text/css" />
</head>
<body>
<div id="spreadsheet"></div>
</body>
<script>
var data = [
['1234'],
['1234']
];
function InputMaxLenght(maxLength) {
// Methods
this.closeEditor = function (cell, save) {
var value = cell.children[0].value;
cell.innerHTML = value;
return value;
},
this.openEditor = function (cell) {
// Create input
var element = document.createElement('input');
element.maxLength = maxLength;
// // Update cell
cell.classList.add('editor');
cell.innerHTML = '';
cell.appendChild(element);
// // Focus on the element
element.focus();
},
this.getValue = function (cell) {
return cell.innerHTML;
}
this.setValue = function (cell, value) {
console.log(value);
cell.innerHTML = value;
}
}
jexcel(document.getElementById('spreadsheet'), {
data: data,
columns: [
{ type: 'text', title:'MaxLenght', width:100, editor: new InputMaxLenght(4) },
]
});
</script>
</html>