Disable the context menu on a flexsheet

Originally Posted 23 October 2015, 3:18 am EST

  • Originally Posted 23 October 2015, 3:18 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!
  • Reply

    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
  • Reply

    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
  • Reply

    Any updates on this? I'd like to disable context menu too.
  • Reply

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

    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
  • Reply

    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.
  • Reply

    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
  • Reply

    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?
  • Reply

    Hi,
    We are looking into the issue.

    Thanks,
    Manish Kumar Gupta
  • Reply

    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
  • Reply

    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!
  • Reply

    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
  • Reply

    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.
  • Reply

    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.
  • Reply

    For typescript, you may try something like this:
    (flexsheet as any)._contextMenu.show = function(){}
  • Reply

    Thank you Sharad. That works for me.
  • Reply

    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