Hi there,
I just started using Handsontable and I’m trying to use getData() within the afterChange hook so that I can retrieve the data from the table whenever a cell is updated. Problem is that I keep getting “this.getData is not a function”. I also tried within the afterRender hook and I still get the same result. I am using the React wrapper and the my component code is below.
Any help would be much appreciated!
class myTable extends Component {
constructor(props) {
super(props);
this.tableSettings = {
data: [
[5, null, null, 5, null, null, 7, null, null, 7, null, null],
[5.5, null, null, 5.5, null, null, 7.5, null, null, 7.5, null, null],
[6, null, null, 6, null, null, 8, null, null, 8, null, null],
[6.5, null, null, 6.5, null, null, 8.5, null, null, 8.5, null, null],
[5, null, null, 5, null, null, 7, null, null, 7, null, null],
[5.5, null, null, 5.5, null, null, 7.5, null, null, 7.5, null, null],
[6, null, null, 6, null, null, 8, null, null, 8, null, null],
[6.5, null, null, 6.5, null, null, 8.5, null, null, 8.5, null, null]
],
afterChange: () => {
console.log(this.getData());
},
colHeaders: true,
rowHeaders: true,
colWidths: [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],
rowHeights: [50, 50, 50, 50, 50, 50, 50, 50],
className: 'htCenter htMiddle',
cells: setCellRules,
mergeCells
};
}
render() {
return (
<Fragment>
<HotTable id="myTable" settings={this.tableSettings} />
</Fragment>
);
}
}
export default myTable;