You can specify menu items using the items property.
See also the list of supported menu actions.
JavaScript
const contextMenu = new DayPilot.Menu({ items: [ {text: "Show event ID", onClick: args => { DayPilot.Modal.alert("Event id: " + args.source.id());} }, {text: "Show event text", onClick: args => { DayPilot.Modal.alert("Event text: " + args.source.text());} }, {text: "Show event start", onClick: args => { DayPilot.Modal.alert("Event start: " + args.source.start());} }, {text: "Delete", onClick: args => { dp.events.remove(args.source); } } ]});
See also:
- DayPilot.Menu.items (API)
ASP.NET WebForms
.aspx
<daypilot:daypilotmenu id="DayPilotMenu1" runat="server" ClientObjectName="menu"> <DayPilot:MenuItem Text="Open" Action="JavaScript" JavaScript="alert('Opening event (id ' + e.value() + ')');" ></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 Text="Delete (JavaScript using callback)" Action="JavaScript" Command='Delete' JavaScript="if (confirm('Do you really want to delete event ' + e.text() + ' ?')) ctl00_ContentPlaceHolder1_DayPilotCalendar1.eventMenuClickCallBack(e, command);"></DayPilot:MenuItem> </daypilot:daypilotmenu>
Code behind (C#)
protected void Page_Load(object sender, EventArgs e) { DayPilotMenu1.MenuItems.Clear(); // <DayPilot:MenuItem Text="Open" Action="JavaScript" JavaScript="edit(e);" ></DayPilot:MenuItem> MenuItem open = new MenuItem(); open.Text = "Open"; open.Action = MenuItemAction.JavaScript; open.JavaScript = "edit(e);"; DayPilotMenu1.MenuItems.Add(new MenuItem()); // ... }
ASP.NET MVC
@Html.DayPilotMenu("menu1", new DayPilotMenuConfig { Items = new DayPilot.Web.Mvc.MenuItemCollection() { new DayPilot.Web.Mvc.MenuItem { Text = "Open", Action = MenuItemAction.JavaScript, JavaScript = "alert(e.value());"}, new DayPilot.Web.Mvc.MenuItem { Text = "Delete", Action = MenuItemAction.CallBack, Command = "Delete"} } })