When trying to select certain rows based on whether a row is selected or deselected, I encountered an issue. If a row is selected, all rows with an index lower than the selected row's index should also be selected. However, a problem arises when the setSelected(true) or setSelected(false) function triggers the onRowSelected event repeatedly, creating an infinite loop.
this.gridOptions.onRowSelected = function(event) {
var rowIndexSelected = event.rowIndex;
if (event.node.selected) {
vm.gridOptionsSuiviPrestataire.api.forEachNode(function(rowNode, index) {
if (index < rowIndexSelected) {
rowNode.setSelected(true);
}
});
} else {
vm.gridOptionsSuiviPrestataire.api.forEachNode(function(rowNode, index) {
if (index > rowIndexSelected) {
rowNode.setSelected(true);
}
});
}
};
Is there a workaround to achieve this functionality without triggering the onRowSelected event listener endlessly, perhaps by using a flag to prevent executing the code within the method?