We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to get relevant cell on contextMenuItemSelect event

I want to get the exact cell (reference including the address, not just the value) the onContextMenuItemSelect event only pass the menu item and not the cell on which the context menu was opened. I was looking for a context menu item click event but I didn't find any. Is there a way to get a reference of the cell when a context menu is opened?


 Here is a codesandbox.


3 Replies 1 reply marked as answer

SP Sangeetha Priya Murugan Syncfusion Team March 27, 2023 09:27 AM UTC

Hi Majid,


Your requirement can be achievable by using the getActiveSheet method, activeCell and selectedRange property. The activeCell property returns the current sheet active cell and selectedRange property returns the range of selected cells in active sheet as shown below.


Code Block:


 

 

 function contextMenuItemSelect(args) {

    let sheet = spreadsheet.getActiveSheet();

    console.log(sheet.activeCell); // active cell

    console.log(sheet.selectedRange); // returns the selected range

  }

 

 


For your convenience we have prepared the sample based on our suggestion. Please find the link below.


Sample Link: https://stackblitz.com/edit/react-mcbnsq?file=index.js


Marked as answer

MR Majid Razmjoo March 27, 2023 10:35 PM UTC

Thank you. This is exactly what I needed.



SP Sangeetha Priya Murugan Syncfusion Team March 28, 2023 06:52 AM UTC

Hi Majid,


We are happy to hear that your issue has been resolved. Kindly get back to us if you need any further assistance.


Regards,

Sangeetha M


Loader.
Up arrow icon