Cancel CellDoubleClick/InvalidOperation event

Posted by: nhan.thanh.nguyen on 2 October 2023, 9:16 pm EST

    • Post Options:
    • Link

    Posted 2 October 2023, 9:16 pm EST - Updated 2 October 2023, 9:21 pm EST

    Hi team,

    My sheet is currently in protected mode, so when I double-click on cell, an invalidOperation warning is showing up. Is there any way that the warning does not show in this case?

    I’m using spreadjs v16.2.3 with ReactJs

    Thanks and Best Regards!

    Nhan Nguyen

  • Posted 3 October 2023, 5:27 pm EST - Updated 3 October 2023, 5:37 pm 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);
    
    
        }

    sample: https://jscodemine.grapecity.com/share/2-vzIGoaZ0uBnpipTIewBw/?IsEmbed=false&Theme=Unset&PreviewDirection=0&IsEditorShow=true&IsExplorerShow=true&IsPreviewShow=true&IsConsoleShow=true&IsRunBTNShow=false&IsResetBTNShow=false&IsOpenInCodemineBTNShow=false&PanelWidth=20&PanelWidth=50&PanelWidth=30&defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fsrc%2Fapp.jsx"%2C"%2Fpackage.json"%2C"%2Fsrc%2Fdata.jsx"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.jsx"}

    Regards,

    Avinash

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels