This is a migrated thread and some comments may be shown as answers.
create context menus Scheduler client
7 Answers 39 Views
This is a migrated thread and some comments may be shown as answers.
Jose Granja
Top achievements
Rank 1
Jose Granja asked on 21 Apr 2011, 11:43 AM
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

7 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 21 Apr 2011, 04:04 PM
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.

0
Jose Granja
Top achievements
Rank 1
answered on 21 Apr 2011, 04:25 PM
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¿?
0
Jose Granja
Top achievements
Rank 1
answered on 21 Apr 2011, 04:29 PM
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
0
Jose Granja
Top achievements
Rank 1
answered on 21 Apr 2011, 04:32 PM
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? 
0
Veronica
Telerik team
answered on 27 Apr 2011, 10:13 AM
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.

0
Jose Granja
Top achievements
Rank 1
answered on 27 Apr 2011, 10:22 AM
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
0
Veronica
Telerik team
answered on 29 Apr 2011, 01:14 PM
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.

Asked by
Jose Granja
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Jose Granja
Top achievements
Rank 1
Share this question
or