Hi Dan,
I'll try to make my questions/problems as clear as possible. I'm using DayPilot Calendar for MVC3 Razor and I'm trying to use a context menu that is specific to the user. Only an admin or the user who created the event should have the option to delete/edit it. So I've defined two different context menus in my view. Here's the code:
@Html.DayPilotMenu("menu_priveledged_user", new DayPilotMenuConfig
{
CssClassPrefix = "menu_",
UseShadow = true,
Items = new DayPilot.Web.Mvc.MenuItemCollection
{
new DayPilot.Web.Mvc.MenuItem { Text = "Open", Action = DayPilot.Web.Mvc.Enums.MenuItemAction.JavaScript, JavaScript = "alert(e.value());"},
new DayPilot.Web.Mvc.MenuItem { Text = "Delete", Action = DayPilot.Web.Mvc.Enums.MenuItemAction.CallBack, Command = "Delete"},
new DayPilot.Web.Mvc.MenuItem { Text = "Edit", Action = DayPilot.Web.Mvc.Enums.MenuItemAction.JavaScript, JavaScript = "editEvent(e)"},
}
})
@Html.DayPilotMenu("menu_disallow", new DayPilotMenuConfig
{
CssClassPrefix = "menu_",
UseShadow = true,
Items = new DayPilot.Web.Mvc.MenuItemCollection
{
new DayPilot.Web.Mvc.MenuItem { Text = "Open", Action = DayPilot.Web.Mvc.Enums.MenuItemAction.JavaScript, JavaScript = "alert(e.value());"},
new DayPilot.Web.Mvc.MenuItem { Text = "<span style='color:gray'>Delete</span>", Action = DayPilot.Web.Mvc.Enums.MenuItemAction.JavaScript, JavaScript = "void(0);"},
new DayPilot.Web.Mvc.MenuItem { Text = "<span style='color:gray'>Edit</span>", Action = DayPilot.Web.Mvc.Enums.MenuItemAction.JavaScript, JavaScript = "void(0);"}
}
})
When I define my calendar what should I set ContextMenu equal to so that I may use OnBeforeEventRender to specify which events the user is actually allowed to change?
Also, according to the code below, am I correctly setting ContextMenuClientName in OnBeforeEventRender?
protected override void OnBeforeEventRender(BeforeEventRenderArgs e)
{
if (user = admin || user = create_user)
{
// open context menu that allows for editing and deleting of this event
e.ContextMenuClientName = "menu_priveledged_user";
}
else
e.ContextMenuClientName = "menu_disallow";
}