How to Retrieve Clicked Cell Value in SpreadJS Using GC.Spread.Sheets.Events.In

Posted by: bruno.bueno on 21 September 2023, 10:35 pm EST

  • Posted 21 September 2023, 10:35 pm EST

    Hello fellow SpreadJS enthusiasts,

    I’m currently working on a project using SpreadJS, and I’m facing an issue related to the GC.Spread.Sheets.Events.InvalidOperation event. Specifically, I want to retrieve the value of the clicked cell when this event is triggered, but I’m not sure how to do it.

    Here’s the scenario:

    I have set up an event listener for the GC.Spread.Sheets.Events.InvalidOperation event in my SpreadJS application.

    When this event is fired, I need to access the value of the cell that was clicked by the user.

    My question is, how can I obtain the clicked cell value when handling the InvalidOperation event?

    I would greatly appreciate any guidance or examples from those who have experience with SpreadJS or have encountered a similar scenario. Please share your insights or code snippets if possible.

    Thank you in advance for your help!

    Best regards,

    Bruno

  • Posted 21 September 2023, 11:01 pm EST - Updated 24 September 2023, 3:42 pm EST

    Hi Bruno,

    The Invalid Operation is triggered by many actions like when trying to edit a locked cell in a protected sheet, when the drag drop is invalid, when drag fill is invalid, etc. You could refer to the following enumeration for different types of InvalidOperation: https://www.grapecity.com/spreadjs/api/v15/enums/GC.Spread.Sheets.InvalidOperationType#enumeration-invalidoperationtype

    As per my understanding, you want to know the active cell(s) when the Event is triggered. You could use the following code snippet:

    
    spread.bind(GC.Spread.Sheets.Events.InvalidOperation, (sender, args) => {
        console.log("Invalid Operation");
        console.log(args);
        let sheet = args.sheet;
        let activeSelection = sheet.getSelections()[0];
        console.log(activeSelection);
    })

    Sample: https://jscodemine.grapecity.com/share/Xmf2HaykMkO7BCKg9NEV9Q/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fpackage.json"%2C"%2Fsrc%2Fapp.js"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.js"}

    If it doesn’t satisfy your requirement, kindly let us know which operation you are performing so that we could help you accordingly. A video/gif of the operation would be really helpful. You could also fork the above sample, modify it and share it with us.

    References:

    InvalidOperation Event: https://www.grapecity.com/spreadjs/api/v15/classes/GC.Spread.Sheets.Events#invalidoperation

    getSelections method: https://www.grapecity.com/spreadjs/api/v15/classes/GC.Spread.Sheets.Worksheet#getselections

    Regards,

    Ankit

Need extra support?

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

Learn More

Forum Channels