Disable the context menu on a flexsheet

Posted by: amyl on 14 September 2017, 2:25 am EST

  • Posted 14 September 2017, 2:25 am EST

    I am currently evaluating flexsheet - I would like to disable the context menu on a sheet without customizing ContextMenu.js or FlexSheet.js, is there a way to do that?

    Thanks!

  • Posted 14 September 2017, 2:25 am EST

    Hello,

    I apologize for the delayed response.

    The context menu functionality is implemented in the FlexSheet sample by using the additional “ContextMenu.js” file. The contextMenu property has not been exposed at the FlexSheet level in the sample. So, it would not be possible to disable the context menu without customizing the ContextMenu.js or FlexSheet.js files.

    However, I have posted an enhancement request to expose the contextMneu property in the FlexSheet control so that the user can enable or disable the context menu for the FlexSheet as per the requirements. It might be implemented in the FlexSheet if the development team finds it to be feasible.

    Thanks,

    Manpreet Kaur

  • Posted 14 September 2017, 2:25 am EST

    Any updates on this? I’d like to disable context menu too.

  • Posted 14 September 2017, 2:25 am EST

    Hello,

    Currently, we do not have any update regarding this issue, it is still with the development team. It might be implemented in the future releases of FlexSheet.

    I have requested the concerned team for an update. I will let you know as soon as I get any information in this regard.

    Thanks,

    Manpreet Kaur

  • Posted 14 September 2017, 2:25 am EST

    A year later… Any updated? I’m having the same issue and have a support ticket in on this.

  • Posted 14 September 2017, 2:25 am EST

    Hello,

    The enhancement request is still with the development team and they are working on it. We have requested the development team for an update. We will let you know as soon as we get any information in this regard.

    Thanks,

    Manpreet Kaur

  • Posted 14 September 2017, 2:25 am EST

    I got the following fiddle for an example on how to customize the context menu popup.

    jsFiddle

    While it doesn’t disable a popup, it does allow you to replace it.

  • Posted 14 September 2017, 2:25 am EST

    Hi Reed,

    Thanks for sharing sample provided you.

    You can prevent displaying contextmenu in FlexSheet by handling contextmenu event and calling e.preventDefault() with capturing event.

    For reference, please see the updated fiddle that implements the same.

    Thanks,

    Manish Kumar Gupta

  • Posted 21 September 2017, 8:16 am EST

    The above solution does not work on an iPad (using Safari or Chrome). Do you have a solution that will also work on tablets or know which event to prevent from firing?

  • Posted 22 September 2017, 1:53 am EST

    Hi,

    We are looking into the issue.

    Thanks,

    Manish Kumar Gupta

  • Posted 24 September 2017, 7:29 pm EST

    Hi,

    You need to handle touchstart event and wait for 501ms to hide contextmenu. Since contextmenu gets opened in 500ms.

    Please refer to the updated fiddle for the same.

    http://jsfiddle.net/mkgupta911/bx7cto2u/7/

    Thanks,

    Manish Kumar Gupta

  • Posted 11 January 2021, 7:11 am EST

    Forgive me for resurrecting an old thread, but I think this is still relevant…

    It is several years after Manpreet posted “The enhancement request is still with the development team and they are working on it”. Yet, it still does not seem possible to disable the context menu on a FlexSheet.

    Manish generously provided sample code to suppress the context menu. The code successfully overrides the ‘contextmenu’ event on a desktop browser. But the code does not work to override the ‘touchstart’ event on a mobile browser because it relies on calling a private method theSheet._contextMenu.hide().

    Even if you can get the code to work, I feel it is a hack to disable a feature this way. A better way would be to offer a public property with which we can disable the feature. FlexSheet makes lots of useful properties available such as ‘allowAddNew’, ‘allowMerging’, etc. Surely it would be relatively easy for you to add an ‘allContextMenu’ property?

    Kindly revisit the topic with the development team.

    Thanks!

  • Posted 12 January 2021, 4:56 pm EST

    Hi Stephen,

    We are sorry but it seems like this request got lost somehow and there has been no activity on this case(#136188) for a long time. So I’ve increased the priority for this case and have asked the dev team for an update. I’ll provide you with an update as soon as I get more information.

    Till then you may use the following code as a workaround:

    flexsheet._contextMenu.show = function(){}
    

    Regards

  • Posted 13 January 2021, 5:42 am EST

    Thank you Sharad. Overwriting the show() method does the trick.

    Looking forward to hearing from the dev team and seeing a public property to manage this.

  • Posted 13 January 2021, 12:36 pm EST

    Correction… On trying to override the show() method in my Angular project, I get the same scope error again:

    property '_contextMenu' is private and only accessible within class 'FlexSheet'
    

    JavaScript seems to allows the scope violation, TypeScript does not.

    So, it would seem there is currently no way to safely suppress the context menu.

  • Posted 13 January 2021, 3:19 pm EST

    For typescript, you may try something like this:

    (flexsheet as any)._contextMenu.show = function(){}
    
  • Posted 14 January 2021, 9:10 am EST

    Thank you Sharad. That works for me.

Need extra support?

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

Learn More

Forum Channels