I have a Handsontable in a React JS application. Currently there are 2 actions that the table is used for:
- Processing the data in some calculations
- Saving the data to the database.
I have minSpareRows set to 1 in the table, and the table’s “data” is tied to the application’s State. So, whenever I process or save data, it always includes a spare row in the data set being processed. So, my question is, what’s the cleanest way to exclude the “spare row (or, empty row)” from the data set when I’m doing things with it? Here is how I’m defining my table (kind of… I removed a bunch of junk to make it more succinct):
constructor(props) {
super(props);
const myState = this.props.state;
this.state.hotSettings = {
data: myState.ChildRows,
width: “80%”,
height: 200,
rowHeaders: true,
colHeaders: Object.keys(myState.ChildRows[0]),
columns: this.assembleColumns(),
minSpareRows: 1,
contextMenu: true
};
}
this.assembleColumns = () => {
return [{ data: “My Field” }];
}
EDIT: Oh, and here’s how I’m prepping the data to be processed:
runScripts = () => {
const processProps = this.props;
var promise = new Promise(function (resolve, reject) {
generateScripts(processProps.state, “standard”, processProps.currentUser)
resolve(true);
})
promise.then(bool => this.setState({ displayScripts: true }));
}