create context menus Scheduler client

8 posts, 0 answers
  1. Jose Granja
    Jose Granja avatar
    84 posts
    Member since:
    Oct 2009

    Posted 21 Apr 2011 Link to this post

    Hi,

    is it possible to create the context menus dynamically in the client side? And further more is it possible to created them based on some appointment properties? 

    I'm looking the documentation but it doesn't say anything regarding that.

    regards,

    jose
  2. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 21 Apr 2011 Link to this post

    Hello Jose Granja,

    As I understand your requirement is to create context menus dynamically. In that case you don't need to create the context menu on the client. You need to create you context menus in the markup and just set the corresponding ContextMenuID in the AppointmentDataBound event as described in the end of this help topic.

    Best wishes,
    Veronica Milcheva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Jose Granja
    Jose Granja avatar
    84 posts
    Member since:
    Oct 2009

    Posted 21 Apr 2011 Link to this post

    I just did that:

    RadScheduler1.AppointmentContextMenus.Add(GetDefaultContextMenu());
    RadScheduler1.AppointmentContextMenus.Add(GetContextMenusAppointment());
     
    protected RadSchedulerContextMenu GetDefaultContextMenu()
            {
                RadSchedulerContextMenu RadSchedulerContextMenu = new RadSchedulerContextMenu();
                RadSchedulerContextMenu.ID = "DefaultContextMenu";
     
                RadMenuItem RadMenuItem1 = new RadMenuItem();
                RadMenuItem1.Text = "Delete";
                RadMenuItem1.Value = "CommandDelete";
     
                RadMenuItem RadMenuItem2 = new RadMenuItem();
                RadMenuItem2.Text = "Edit";
                RadMenuItem2.Value = "CommandEdit";
     
                RadSchedulerContextMenu.Items.Add(RadMenuItem1);
                RadSchedulerContextMenu.Items.Add(RadMenuItem2);
     
                return RadSchedulerContextMenu;
            }
     
            protected RadSchedulerContextMenu GetContextMenusAppointment()
            {
                RadSchedulerContextMenu RadSchedulerContextMenu = new RadSchedulerContextMenu();
                RadSchedulerContextMenu.ID = "AppointmentContextMenu";
     
                RadMenuItem RadMenuItem1 = new RadMenuItem();
                RadMenuItem1.Text = "Delete";
                RadMenuItem1.Value = "CommandDelete";
     
                RadMenuItem RadMenuItem2 = new RadMenuItem();
                RadMenuItem2.Text = "Edit";
                RadMenuItem2.Value = "CommandEdit";
     
                RadMenuItem RadMenuItem3 = new RadMenuItem();
                RadMenuItem3.Text = "Send Reminder";
                RadMenuItem3.Value = "CommandEdit";
     
                RadSchedulerContextMenu.Items.Add(RadMenuItem1);
                RadSchedulerContextMenu.Items.Add(RadMenuItem2);
                RadSchedulerContextMenu.Items.Add(RadMenuItem3);
     
                return RadSchedulerContextMenu;
            }

    and then in the appointment created event:
    function appointmentCreated(sender, eventArgs) {
        var $ = $telerik.$; // jQuery alias
        var apt = eventArgs.get_appointment();
        var AppointmentContainer = GetAppContainer(apt);
        var prependString = undefined;
     
        apt.set_toolTip(apt.get_attributes().getAttribute("ToolTip"));
        apt.ContextMenuID = "AppointmentContextMenu";
         
        if (IsBusyAppointment(apt)) {
            apt.ContextMenuID = "DefaultContextMenu";
        }
    }

    And it's always getting the same context menu... it's not changing when I bind it on the client side... Am I doing something wrong¿?
  4. Jose Granja
    Jose Granja avatar
    84 posts
    Member since:
    Oct 2009

    Posted 21 Apr 2011 Link to this post

    I've try if the context menus are saved in the appointment and they are. And in the scheduler object I can see as well that the context menus are there... I just not doing anything with the info I guess. The info is there and right
  5. Jose Granja
    Jose Granja avatar
    84 posts
    Member since:
    Oct 2009

    Posted 21 Apr 2011 Link to this post

    My data binding is webservice so I can't do that contextmenuid on the server and has to be done by javascript... anyway it should do the binding after the appointment is created right? 
  6. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 27 Apr 2011 Link to this post

    Hello Jose Granja,

    Could you please send me your full code so I can inspect it and help you?

    Thank you!

    Regards,
    Veronica Milcheva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  7. Jose Granja
    Jose Granja avatar
    84 posts
    Member since:
    Oct 2009

    Posted 27 Apr 2011 Link to this post

    Hi,

    I'm afraid our project is too big and I don't really have time to make a demo right now... I only wanted to know if it's possible binding each appointment to a different context menu on the webservice binding mode. The examples I've seen are all for the server binding mode. Could you provide a working example based on the webservice mode?

    regards and many thanks

    jose
  8. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 29 Apr 2011 Link to this post

    Hello Jose Granja,

    I've prepared a sample project to show you how to change the context menus according to some additional checks. You can subscribe to the OnAppointmentContextMenu client-side event and use the following code in the handler:

    function OnClientAppointmentContextMenu(sender, args) {
               var apt = args.get_appointment();
               if (apt.get_subject() == "a") {
                   apt.set_contextMenuID("DefaultContextMenu");
               }
               else {
                   apt.set_contextMenuID("ContextMenu1");
               }
           }

    In my code I am setting the DefaultContextMenu only to those appointments with subject  equal to"a". 

    Please take a look at the attached .zip file to find the full code. 

    Regards,
    Veronica Milcheva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top