search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to Hide Context Menu Item

Asked by Robert
2 months ago.

I have a scenario where I need to toggle an Event context menu item (Cancel / Activate) so that the context menu only shows the appropriate option for the event.

  • Active Events need to display the Cancel Item and Hide (not disable) the Activate Item
  • Cancelled Events need to display the Activate Item and Hide (not disable) the Cancel Item

I am looking for an action similar to below that will allow be to set the visibility of the item to false. I am unable to find anything in the documentation that describes this. (I am aware "show = false" is not a valid option). I would also rather not use multiple context menus as there are 7 other items in the menu.

if (e.data.tags.isCancelled) {
   args.menu.items[context.CancelShift].show = false;
} else {
   args.menu.items[context.ActivateShift].show = false;
}

Currently Using DayPilot Pro for JavaScript 2019.1.3572

Thanks!

Answer posted by Dan Letecky [DayPilot]
2 months ago.

You can do this in onShow event handler - it's called before the menu is displayed and you can use it to modify the context menu items.

You can find an example here:
https://api.daypilot.org/daypilot-menu-onshow/

Instead of "disabled" menu item property, use "hidden":
https://api.daypilot.org/daypilot-menu-items/

New Reply
This reply is
Your name (optional):