Dynamicaly Create RadScheduler Contextmenu

9 posts, 0 answers
  1. Chandan Kumar
    Chandan Kumar avatar
    68 posts
    Member since:
    Mar 2010

    Posted 01 Apr 2010 Link to this post

    Hi Sir,

    i Want to Create Dynamic RadScheduler Context Menu.

    Like In Blank Row Of Scheduler Context Menu Appear New and Disable Paste Menu.

    And Where Appointment is given Then There Context Menu Appear Like Edit, Copy, Paste, Cut etc. When I Copy Any Appointment and then Again go to blank Row then Context menu appear New And Paste Option. How can Achive this type of Condition. Please Help Me.


    Thanks
    Chandan Kumar.
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 01 Apr 2010 Link to this post

    Hi Chandan,

    RadScheduler exposes two different types of context menus:

    Appointment context menu

    Time slot context menu

    Additionally, you can conditionally set the ContextMenuID property to specify which context menu to open for a given appointment:

    protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
    {
       e.Appointment.ContextMenuID = "SchedulerAppointmentContextMenu2";
    }

    I have also attached a simple demo of using context menus to copy/cut and paste appointments.


    Greetings,
    Peter
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chandan Kumar
    Chandan Kumar avatar
    68 posts
    Member since:
    Mar 2010

    Posted 01 Apr 2010 Link to this post

    Hello Sir, I Know These things and thanks, But i want to create dinamic Menu item in these two category of Rad Scheduler Contecxt menu. Or i want to enable or  Disable of some menu Items in Rad Schedule Context Menu According to Some Condition. So please help me to handdle this problem.


    Thanks 
    Chandan  
  5. Matt
    Matt avatar
    29 posts
    Member since:
    Oct 2011

    Posted 15 Jul 2014 in reply to Chandan Kumar Link to this post

    I'm also trying to figure this out. I need to be able to set the Appointment Context Menu text at runtime. Anyone? 
  6. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 18 Jul 2014 Link to this post

    Matt,

    Please look at this forum post, where the same question has already been answered.

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. David
    David avatar
    37 posts
    Member since:
    Aug 2014

    Posted 03 Oct 2014 Link to this post

    @Hristo Valyavicharski,

     Please look at this forum post  where the OP states that the question was not answered.

    Yes, at run-time you can select which of the context menus that were created in design time are to be attached to a given appointment. Check.

    Matt, Chandan Kumar, and I are looking for the run-time capability to modfiy the context menu based on other criteria, such as is shown in this help topic for the TreeView control
       For instance I have a table of resources that is editable by the end user. I want the context menu to allow assignment of these resources.

      In pseudo code I would be looking for something like:

    protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
    {
       RadSchedulerContextMenu menu = e.Appointment.ContextMenu;
       RadSchedulerContextMenuItem item = new RadSchedulerContextMenuItem("Display Text","Command Name","Command Args", hasChildren);
        RadSchedulerContextMenuItem node = menu.Items.FindByText("Home");
        node.Add(item);
     
    }

    Is this possible?

      
  8. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 08 Oct 2014 Link to this post

    Hi David,

    Try this approach:

    Define two context menus and make the second invisible:
    <telerik:RadScheduler ID="RadScheduler1" runat="server" DataDescriptionField="Description" DataEndField="End" DataKeyField="ID" DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID" DataReminderField="Reminder"
        OnAppointmentDataBound="RadScheduler1_AppointmentDataBound" OnAppointmentCreated="RadScheduler1_AppointmentCreated"
        DataSourceID="sdsAppointments" DataStartField="Start" DataSubjectField="Subject">
        <AppointmentContextMenus>
            <telerik:RadSchedulerContextMenu ID="ContextMenu1" runat="server" OnClientItemOpening="OnClientItemOpening">
                <Items>
                    <telerik:RadMenuItem Text="Copy">
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadSchedulerContextMenu>
            <telerik:RadSchedulerContextMenu ID="ContextMenu2" runat="server" Visible="false">
            </telerik:RadSchedulerContextMenu>
        </AppointmentContextMenus>
    </telerik:RadScheduler>

    Handle the OnAppointmentCreated event:

    protected void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
    {
        if (e.Appointment.Subject == "test")
        {
            e.Appointment.ContextMenuID = ContextMenu1.ID;
        }
        else
        {
            e.Appointment.ContextMenuID = ContextMenu2.ID;
        }
    }

    I hope this helps.

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  9. David
    David avatar
    37 posts
    Member since:
    Aug 2014

    Posted 08 Oct 2014 in reply to Hristo Valyavicharski Link to this post

    Thank you for the response.

      It appears that the scheduler doesn't have the capabilities I am looking for and I will have to work around this limitation.

     Specific capabilities not included in the current version are:

     - Change TimeSlot context menus at run time using a RadScheduler1_TimeSlotCreated() event similar to your post directly above. As current, the RadScheduler only allows for one TimeSlot context menu that is built in design mode.

     - Add/change/update the menu items within a context menu during run time. Yes, you can create multiple different Appointment Context menus during design time and switch between them at run time. However you cannot dynamically add menu items to either an Appointment Context or TimeSlot Context menu.

          For example, appointments are assigned to a worker. The context menu has "Assign to Worker" as a main item. Through the 'AppointmentCreated' event, programatically grab a list of workers and add sub-items to the context menu.
        This dynamic capability exists in the RadMenu, as shown here: http://www.telerik.com/help/aspnet-ajax/menu-context-runtime.html

  10. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 10 Oct 2014 Link to this post

    David,

    This approach with adding items on the server is not suitable for this scenario. Here you want to have different context menus for every appointment. So this means you have to create separate context menu for every appointment. This is not recommended. Or if you have one menu it is not possible to change its items on the server because when the page is loaded all Scheduler's appointments will created. This what you could do is to add new menu items on the client. For example create one context menu and dynamically add/remove items in the OnClientAppointmentContextMenu event:
    <telerik:RadScheduler
        ID="RadScheduler1"
        runat="server"
        DataDescriptionField="Description"
        DataEndField="End"
        DataKeyField="ID"
        DataRecurrenceField="RecurrenceRule"
        DataRecurrenceParentKeyField="RecurrenceParentID"
        OnClientAppointmentContextMenu="OnClientAppointmentContextMenu"
        DataReminderField="Reminder"
        OnAppointmentDataBound="RadScheduler1_AppointmentDataBound"
        OnAppointmentCreated="RadScheduler1_AppointmentCreated"
        DataSourceID="sdsAppointments"
        DataStartField="Start"
        DataSubjectField="Subject">
        <AppointmentContextMenus>
            <telerik:RadSchedulerContextMenu ID="ContextMenu1" runat="server" OnClientItemOpening="OnClientItemOpening">
                <Items>
                    <telerik:RadMenuItem Text="Copy">
                    </telerik:RadMenuItem>
                </Items>
            </telerik:RadSchedulerContextMenu>
        </AppointmentContextMenus>
    </telerik:RadScheduler>
    <script>
          var menu;
     
          function pageLoad() {
              menu = $find("<%= ContextMenu1.ClientID %>");
          }
     
          function OnClientAppointmentContextMenu(sender, args) {          
              var rootItem = new Telerik.Web.UI.RadMenuItem();
              rootItem.set_text("New Root Item");
              menu.get_items().add(rootItem);
          }
      </script>


    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017