Posted 3 October 2023, 6:16 am EST - Updated 3 October 2023, 6:21 am EST
Cancel CellDoubleClick/InvalidOperation event
Posted by: nhan.thanh.nguyen on 3 October 2023, 6:16 am EST
-
-
Posted 4 October 2023, 2:27 am EST - Updated 4 October 2023, 2:37 am EST
Hi,
For this, you may unbind the Designer events for invalid operations. Please refer to the following code snippet and let me know if you face any issues.
var spreadInstance = designerInstance.getWorkbook(); spreadInstance.unbind(GC.Spread.Sheets.Events.InvalidOperation + '.GC_Designer_Events') Please note that the dialog would be disabled for the following invailidType GC.Spread.Sheets.InvalidOperationType.changeSheetName: GC.Spread.Sheets.InvalidOperationType.copyPaste: GC.Spread.Sheets.InvalidOperationType.table: GC.Spread.Sheets.InvalidOperationType.pivotTable: GC.Spread.Sheets.InvalidOperationType.dragDrop: GC.Spread.Sheets.InvalidOperationType.dragFill: GC.Spread.Sheets.InvalidOperationType.cutProtected: GC.Spread.Sheets.InvalidOperationType.editProtected: GC.Spread.Sheets.InvalidOperationType.dataObjectCellTypeInsertData: GC.Spread.Sheets.InvalidOperationType.customName:
Further if you want to disable for only this case you need to prevent the double click before it is handled by designer. Please refer to the following code snippet and let me know if you face any issues.
componentDidMount() { //workaround for handling double click let spreadInstance = GC.Spread.Sheets.findControl(document.querySelector("div[gcUiElement='gcSpread']")); let activeSheet = spreadInstance.getActiveSheet(); spreadInstance.getHost().addEventListener('dblclick', (event) => { console.log('inside'); let activeCell = activeSheet.getCell(activeSheet.getActiveRowIndex, activeSheet.getActiveColumnIndex); if (activeSheet.options.isProtected && activeCell.locked()) { console.log('preventing the double click'); event.preventDefault(); event.stopImmediatePropagation(); } },true); }
Regards,
Avinash