The context menu will be activated on event right click, provided that the menu is defined (ContextMenu property) and the EventRightClickHanding is set to "ContextMenu" (default).

See also context menu.

JavaScript

See also DayPilot.Scheduler.contextMenu.

dp.contextMenu = new DayPilot.Menu({items: [
  {text:"Edit", onclick: function() { dp.events.edit(this.source); } },
  {text:"Delete", onclick: function() { dp.events.remove(this.source); } },
  {text:"-"},
  {text:"Change background color", onclick: function() { var e = this.source; e.data.backColor = "red"; dp.events.update(e); } },
  {text:"-"},
  {text:"Select", onclick: function() { dp.multiselect.add(this.source); } },
]});

ASP.NET WebForms

<DayPilot:DayPilotScheduler 
  ID="DayPilotScheduler1" 
  runat="server" 
  ContextMenuID="DayPilotMenu2" 
  ContextMenuResourceID="DayPilotMenuRes"
  ...
  >
</DayPilot:DayPilotScheduler>

Context menu control:

<DayPilot:DayPilotMenu ID="DayPilotMenu2" runat="server" CssClassPrefix="menu_default" UseShadow="false">
  <DayPilot:MenuItem Text="Open" Action="JavaScript" JavaScript="alert('Opening event (id ' + e.value() + ')');">
  </DayPilot:MenuItem>
  <DayPilot:MenuItem Text="Send" Action="JavaScript" JavaScript="alert('Sending event (id ' + e.value() + ')');">
  </DayPilot:MenuItem>
  <DayPilot:MenuItem Text="Refresh" Action="JavaScript" JavaScript="dps1.commandCallBack('refresh');">
  </DayPilot:MenuItem>
  <DayPilot:MenuItem Text="-" Action="NavigateUrl"></DayPilot:MenuItem>
  <DayPilot:MenuItem Text="Delete (CallBack)" Action="Callback" Command="Delete"></DayPilot:MenuItem>
  <DayPilot:MenuItem Action="PostBack" Command="Delete" Text="Delete (PostBack)" />
  <DayPilot:MenuItem Action="NavigateUrl" NavigateUrl="javascript:alert('Going somewhere else (id {0})');" Text="NavigateUrl test" />
</DayPilot:DayPilotMenu>

ASP.NET MVC

You can activate the context menu using right click or using an active area.

Context Menu Activated on Event Right Click

scheduler-asp.net-mvc-event-context-menu-right-click.png

The default value of EventRightClickHandling is EventRightClickHandlingType.ContextMenu.

You need to set ContextMenu property to the menu id.

View

@Html.DayPilotMenu("menu", new DayPilotMenuConfig {
  CssClassPrefix = "menu_default",
  Items = new DayPilot.Web.Mvc.MenuItemCollection
  {
    new DayPilot.Web.Mvc.MenuItem { Text = "Open", Action = MenuItemAction.JavaScript, JavaScript = "alert(e.value());"}
  }
})

@Html.DayPilotScheduler("dps", new DayPilotSchedulerConfig {
  BackendUrl = ResolveUrl("~/Scheduler/Backend"),
  ...
  ContextMenu = "menu"
})

Note: The context menu must be declared before it is assigned (Html.DayPilotMenu must be above Html.DayPilotScheduler).

Demo

Context Menu Activated using Active Area

scheduler-asp.net-mvc-event-context-menu-active-area.png

Add an active are in OnBeforeEventRender:

View

@Html.DayPilotMenu("menu", new DayPilotMenuConfig {
  CssClassPrefix = "menu_default",
  Items = new DayPilot.Web.Mvc.MenuItemCollection
  {
    new DayPilot.Web.Mvc.MenuItem { Text = "Open", Action = MenuItemAction.JavaScript, JavaScript = "alert(e.value());"}
  }
})

Backend Controller

protected override void OnBeforeEventRender(BeforeEventRenderArgs e)
{
  e.Areas.Add(new Area().Width(17).Bottom(9).Right(19).Top(3).CssClass("event_action_menu").ContextMenu("menu"));
}

These sample classes (event_action_delete and event_action_menu) are defined in Themes/areas.css (plus Themes/areas directory) so don't forget to include it.

Demo