DayPilot.Menu.onShow

The onShow event handler fires before the context menu is displayed.

You can use it to modify the menu dynamically for the current source object before it becomes visible.

Declaration

DayPilot.Menu.onShow(args)

Parameters

  • args.div (HTML element) - menu DOM element (available since 2025.4.6749)
  • args.menu (DayPilot.Menu) - context menu instance
  • args.source (object) - source object (for example DayPilot.Event)
  • args.preventDefault() - cancels menu activation

Notes

Use this event to enable, disable, or update menu items based on args.source before the menu is shown. Call args.preventDefault() to cancel activation.

Example

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

const sourceEvent = {
  data: {
    tags: {
      readonly: true
    }
  }
};

const menu = new DayPilot.Menu({
  items: [
    {
      text: "Edit...",
      onClick: () => {
        console.log("Showing details...");
      }
    }
  ],
  onShow: (args) => {
    const event = args.source;
    args.menu.items[0].disabled = !!(event.data.tags && event.data.tags.readonly);
  },
  // ...
});

menu.show(sourceEvent);

See Also

DayPilot.Menu.show()

DayPilot.Menu.onHide

DayPilot.Menu.items

DayPilot.Menu Class

Availability

Availability of this API item in DayPilot editions:

LitePro
DayPilot for JavaScript

Lite args missing: div