This is a migrated thread and some comments may be shown as answers.

[Solved] Problem dynamically creating context menus

1 Answer 102 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jeremy Hoehn
Top achievements
Rank 1
Jeremy Hoehn asked on 15 Jan 2010, 06:30 AM
I have a web application that allows different resource types depending on which site it is serving up.  Therefore I need to dynamically generate the context menus for the scheduler.  I have created a method to add these dynamically, but it does not appear to work.  I've searched everywhere and I can't find any examples of anyone building context menus dynamically.  I can't imagine that this wouldn't be supported, so I must be doing something wrong.  Can anyone help me achieve this?

      
       private void buildContextMenu() 
        { 
            rscSchedule.AppointmentContextMenus.Clear(); 
            RadSchedulerContextMenu context = new RadSchedulerContextMenu(); 
            context.ID = "apptContext"
            RadMenuItem edit = new RadMenuItem("Open"); 
            edit.Value = "CommandEdit"
            context.Items.Add(edit); 
            RadMenuItem sep1 = new RadMenuItem(); 
            sep1.IsSeparator = true
            context.Items.Add(sep1); 
            IQueryable<AppointmentResourceType> resourceTypes = Appointments.AppointmentResourceTypesGet(MultiSite.SiteIDGet()); 
            foreach (AppointmentResourceType resourceType in resourceTypes) 
            { 
                RadMenuItem menuRType = new RadMenuItem(resourceType.ResourceTypeDesc); 
                IQueryable<AppointmentResourceTypeItem> statusItems = Appointments.AppointmentResourceTypeItemsGet(resourceType.ResourceTypeID); 
                foreach (AppointmentResourceTypeItem statusItem in statusItems) 
                { 
                    RadMenuItem menuStatus = new RadMenuItem(statusItem.ResourceTypeItemDesc); 
                    menuStatus.Value = statusItem.ResourceTypeItemID.ToString(); 
                    menuRType.Items.Add(menuStatus); 
                } 
                context.Items.Add(menuRType); 
            } 
            RadMenuItem sep2 = new RadMenuItem(); 
            sep2.IsSeparator = true
            context.Items.Add(sep2); 
            RadMenuItem del = new RadMenuItem("Delete"); 
            del.Value = "CommandDelete"
            del.ImageUrl = "~/Presentation/Images/radDelete.gif"
            context.Items.Add(del); 
            rscSchedule.AppointmentContextMenus.Add(context); 
        } 

1 Answer, 1 is accepted

Sort by
0
Dimitar Milushev
Telerik team
answered on 18 Jan 2010, 08:37 AM
Hi Jeremy,

The code seems fine, but it depends at which point during the Page's Lifecycle it is called. I'd recommend you to call it during the Page's Init phase.

Sincerely yours,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Scheduler
Asked by
Jeremy Hoehn
Top achievements
Rank 1
Answers by
Dimitar Milushev
Telerik team
Share this question
or