Hi,
In my ngHandsontable application I have need for both beforeChange
and afterChange
events. Problem is that afterChange
gets triggered twice for the each cell which is causing me a lot of trouble.
This happens even when I comment out everything from it (and from all other events). Is that some common problem? How to prevent it from triggering twice?
These are my settings:
$scope.spreadsheet.settings = {
beforeChange: (changes: Array<any>, source) => {
// commented out
changes.forEach(val => {
var hot = hotRegisterer.getInstance($scope.spreadsheet.hotInstanceID);
});
},
afterChange: (changes: Array<any>, source) => {
// commented out
// if one of this source types - its UPDATE
if (["autofill", "alter", "edit", "paste"].indexOf(source) !== -1) {
// change - row, prop, old, new
changes.forEach(val => {
var hot = hotRegisterer.getInstance($scope.spreadsheet.hotInstanceID);
});
}
},
beforeValidate: (value, row, prop, source) => {
// commented out
},
afterValidate: (isValid, value, row, prop, source) => {
// commented out
},
dropdownMenu: true,
filters: true,
columnSorting: true,
sortIndicator: true,
startRows: 50,
fixedColumnsLeft: 2,
viewportRowRenderingOffset: 15,
viewportColumnRenderingOffset: 50,
manualColumnResize: true,
renderAllRows: true,
wordWrap: true,
stretchH: 'all',
undo: false,
columns: $scope.visibleColumns,
cells: (row, col, prop) => {
var cellProperties: any = {};
if (col === 0) {
cellProperties.renderer = idColumnRenderer;
}
if (readOnlyColumns.indexOf(prop) >= 0) {
cellProperties.readOnly = true;
}
return cellProperties;
}
};
And this is markup
<hot-table hot-id="{{spreadsheet.hotInstanceID}}"
settings="spreadsheet.settings"
min-spare-rows="spreadsheet.minSpareRows"
datarows="spreadsheet.data" >
</hot-table>