DayPilot Month supports context menu for time cells. At this moment it's enabled for a single cell.
ASP.NET WebForms
Setup
- Create a new DayPilotMenu control.
- Assign its ID to DayPilotMonth.ContextMenuSelectionID.
- Handle DayPilotMonth.TimeRangeMenuClick event. This event will be triggered by menu item with Action set to CallBack or PostBack.
.aspx
<DayPilot:DayPilotMonth ID="DayPilotMonth1" runat="server" ... ClientObjectName="dpm" ContextMenuSelectionID="DayPilotMenuSelection" OnTimeRangeMenuClick="DayPilotMonth1_TimeRangeMenuClick" > </DayPilot:DayPilotMonth> <DayPilot:DayPilotMenu ID="DayPilotMenuSelection" runat="server" CssClassPrefix="menu_default"> <DayPilot:MenuItem Action="JavaScript" JavaScript="dpm.timeRangeSelectedCallBack(e.start, e.end);" Text="Create new event (JavaScript)" /> <DayPilot:MenuItem Action="PostBack" Command="Insert" Text="Create new event (PostBack)" /> <DayPilot:MenuItem Action="CallBack" Command="Insert" Text="Create new event (CallBack)" /> <DayPilot:MenuItem Text="-" ></DayPilot:MenuItem> <DayPilot:MenuItem Action="JavaScript" JavaScript="alert('Start: ' + e.start.toString() + '\nEnd: ' + e.end.toString())" Text="Show selection details" /> </DayPilot:DayPilotMenu>
.aspx.cs
protected void DayPilotMonth1_TimeRangeMenuClick(object sender, TimeRangeMenuClickEventArgs e) { switch (e.Command) { case "Insert": createDbEvent(e.Start, e.End); DayPilotMonth1.DataSource = LoadData();
DayPilotMonth1.DataBind(); DayPilotMonth1.Update();
break; } }
ASP.NET MVC
MVC View
@Html.DayPilotMenu("menu", new DayPilotMenuConfig { Items = new DayPilot.Web.Mvc.MenuItemCollection { new DayPilot.Web.Mvc.MenuItem { Text = "Show", Action = MenuItemAction.JavaScript, JavaScript = "alert(e.start + " - " + e.end);"} } }) @Html.DayPilotMonth("dpm_areas", new DayPilotMonthConfig { BackendUrl = ResolveUrl("~/Month/Backend"), ... ContextMenuSelection = "menu" })