AppointmentContetMenus - Submenus programmatically?

3 posts, 1 answers
  1. Thomas
    Thomas avatar
    22 posts
    Member since:
    Mar 2011

    Posted 17 Oct 2011 Link to this post

    Hi!

    I can add AppointmentContextMenus rows programmatically like this:

    foreach (Resource resourceUser in RadScheduler1.Resources.GetResourcesByType("Employee"))
    {
        string availEmployee = resourceUser.Text;
        RadMenuItem resourceItem = new RadMenuItem(availEmployee);
        resourceItem.Attributes["Key"] = resourceUser.Key.ToString();
        resourceItem.Value = "CommandAddAppointment";
        resourceItem.ImageUrl = "/i/Toolbar/Custom/personal.png";
        RadScheduler1.AppointmentContextMenus[0].Items.Add(resourceItem);
    }

    How can I put them into a submenu?
    See my attached picture (a screen dump from Telerik Context Menu Demo), I want my list of employees to end up inside the "Categorize" menurow.

    I'm using v.2011.2.915.40

    Sincerely, Thomas
  2. Answer
    Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 19 Oct 2011 Link to this post

    Hello Thomas,

    You could define the AppointmentContextMenu of RadSheduler as follows:
    <AppointmentContextMenus>
        <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerAppointmentContextMenu">
            <Items>
                <telerik:RadMenuItem Text="Open" Value="CommandEdit" />
                <telerik:RadMenuItem IsSeparator="True" />
                <telerik:RadMenuItem Text="Categorize">
                </telerik:RadMenuItem>
                <telerik:RadMenuItem IsSeparator="True" />
                <telerik:RadMenuItem Text="Delete" Value="CommandDelete" />
            </Items>
        </telerik:RadSchedulerContextMenu>
    </AppointmentContextMenus>

    When you have the AppointmentContextMenu defined you could access its items and sub items as the highlighted code line bellow shows:
    foreach (Resource resourceUser in RadScheduler1.Resources.GetResourcesByType("Employee"))
    {
        string availEmployee = resourceUser.Text;
        RadMenuItem resourceItem = new RadMenuItem(availEmployee);
        resourceItem.Attributes["Key"] = resourceUser.Key.ToString();
        resourceItem.Value = "CommandAddAppointment";
        resourceItem.ImageUrl = "/i/Toolbar/Custom/personal.png";
        RadMenuItemCollection categorizeItems =  
             RadScheduler1.AppointmentContextMenus[0].Items[2].Items;
        categorizeItems.Add(resourceItem);
    }

    More information of defining ContextMenus could be found at the following demo page at our website:
    RadScheduler: Context Menu.

    Hope this helps.

    Greetings,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. Thomas
    Thomas avatar
    22 posts
    Member since:
    Mar 2011

    Posted 20 Oct 2011 Link to this post

    Thank You!
    It works great.

    Sincerely, Thomas
Back to Top