DayPilot.Menu.onShow

The onShow event handler is called before the context menu is displayed. You can use the event handler to dynamically modify the context menu depending on the source object.

Declaration

DayPilot.Menu.onShow(args);

Parameters

  • args.menu (DayPilot.Menu object)
  • args.source (object) - the source object (e.g. DayPilot.Event)
  • args.preventDefault() - cancels the menu activation

Example

This example disables the first menu item if the source event has a readonly tag specified.

dp.events.list = [
  id: 1,
  text: "Event 1",
  start: "2018-10-01",
  end: "2018-10-03",
  resource: "R1",
  tags: {
    readonly: true
  }
];
dp.contextMenu = new DayPilot.Menu({
  items: [
    { text: "Edit...", onClick: function(args) { console.log("Showing details...") } }
  ],
  onShow: function(args) {
    var e = args.source;
    if (e.data.tags && e.data.tags.readonly) {
      args.menu.items[0].disabled = true;
    }
    else {
      args.menu.items[0].disabled = false;
    }
  }
});