Home Unanswered Active Tags New Question

Is it possible to ddd DayPilot:MenuItem items at runtime ?


I'd like to add menu items to a DayPilot:DayPilotMenu at run-time in my c# codebehind.

For example, right click an event, andsay "add subitem x"

Is that possible ?

Thanks, Peter

Asked by peter cli 4 years ago.
Replies
That's no problem. You can do it this way:

MenuItem item = new MenuItem();
item.Text = "Delete";
item.Action = MenuItemAction.CallBack;
item.Command = "delete";
DayPilotMenu1.MenuItems.Add(item);
Comment posted by Dan Letecky 4 years ago.

Thanks Dan.

This puts menu items into all events.

Is there any way to control which event gets the menu item ?

Peter

Comment posted by Anonymous 4 years ago.
You can assign an event-specific context menu in BeforeEventRender event (e.ContextMenuClientName; should be equal to DayPilotMenu.ClientObjectName).

The method of dynamic menu creation from my previous post doesn't allow you to add/remove items during CallBacks/partial PostBacks (only full PostBacks). BeforeEventRender will allow you to create several menus and assign them as needed. Most likely, you won't need a different menu for each event but there will be just a few types of menus based on event type anyway.
Answer posted by Dan Letecky 4 years ago.
I am experiencing a similar situation (different types of events that need different menus) and thought that this was the best solution. The problem is I am working with the month view calendar. The BeforeEventRenderEventArgs are much more limited for the month view and does not include ContextMenuClientName. Is there another way to accomplish this, or would it be possible to enable this in a future release?
Comment posted by Anonymous 3 years ago.
Comment posted by Dan Letecky 3 years ago.
New Reply
This reply is
Your name (optional):

DayPilot for ASP.NET WebForms, DayPilot for ASP.NET MVC, DayPilot for Java