Handsontable example
HTML
<div id="example1" class="hot">
</div>
CSS
</style><!-- Ugly Hack due to jsFiddle issue -->
<script src="https://cdn.jsdelivr.net/npm/handsontable@8.0.0/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable@8.0.0/dist/handsontable.full.min.css">
<script src="https://handsontable.com/docs/8.0.0/scripts/jsfiddle-fixer.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react@16/umd/react.development.js"></script>
<script src="https://cdn.jsdelivr.net/npm/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@handsontable/react@4.0.0/dist/react-handsontable.js"></script>
Babel + JSX
import React from 'react';
import ReactDOM from 'react-dom';
import { HotTable } from '@handsontable/react';
import Handsontable from 'handsontable';
class CustomEditor extends Handsontable.editors.TextEditor {
constructor(props) {
super(props);
}
createElements() {
super.createElements();
this.TEXTAREA = document.createElement('input');
this.TEXTAREA.setAttribute('placeholder', 'Custom placeholder');
this.TEXTAREA.setAttribute('data-hot-input', true);
this.TEXTAREA.maxLength = '3';
this.textareaStyle = this.TEXTAREA.style;
Handsontable.dom.empty(this.TEXTAREA_PARENT);
this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
}
}
class App extends React.Component {
constructor(props) {
super(props);
this.hotSettings = {
startRows: 5,
cells: function(row, column, prop) {
const cellProperties = {};
if (row === 0 && column === 0) {
cellProperties.editor = CustomEditor;
}
return cellProperties;
},
colHeaders: true,
colWidths: 200
};
}
render() {
return (
<div>
<HotTable
id="hot"
settings={this.hotSettings}
/>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById('example1'));