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

[Solved] How can I call the server code from RadContextMenu Item Selecting?

4 Answers 276 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
sabarishbabu
Top achievements
Rank 1
sabarishbabu asked on 29 Jul 2009, 02:20 PM


Subject:  How can I call the server code from RadContextMenu Item Selecting?


1. I have list of appointments populated in the Scheduler which binds from the database in page load event.

2. I need the following

a) Right click on the appointments.

b) Show the context menu.

c) click an item from context menu , how can I call the codebehind function (RadScheduler1_AppointmentUpdate or SchedulerContextMenu_ItemClick)?. How can I get the selected appointmentsvalue like (Subject Id, Start/End Date)?

Note:

      1. Create a context menu item as “Waitinglist”.

2. Select the “Waiting list” from the menu.

3. Update selected appointments in the Database.

Thanks and Regards
Sabarish

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 29 Jul 2009, 03:46 PM
Hi sabarishbabu,

Please, see the RadScheduler Context Menu demo. The context menus functionality is achieved via the client API of the menu and the scheduler, but it can be easily transfered to the server side.


<telerik:RadContextMenu runat="server" ID="SchedulerTimeSlotContextMenu"   
            OnClientItemClicked="timeSlotContextMenuItemClicked"   
            onitemclick="SchedulerTimeSlotContextMenu_ItemClick"  

then comment everything in the client click handler and just leave sender.hide()
function timeSlotContextMenuItemClicked(sender, eventArgs)  
                {  
                    sender.hide();  

Finally, handle server-side menu click similar to this:
protected void SchedulerTimeSlotContextMenu_ItemClick(object sender, RadMenuEventArgs e)  
        {  
            if (e.Item.Text == "Insert")  
            {  
                Appointment a = new Appointment();  
                a.Start = DateTime.Parse(targetSlot.Value).Subtract(RadScheduler1.TimeZoneOffset);  
                a.End = a.Start.AddHours(1);  
                a.Subject = "My custom subject";  
                RadScheduler1.InsertAppointment(a);  
                RadScheduler1.Rebind();  
            }              
        } 



Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
sabarishbabu
Top achievements
Rank 1
answered on 30 Jul 2009, 05:13 AM

Hi Peter,

Thank you for your quick reply.

This is exactly what I need. But, How can I get the selectedappointment Details (DataKeyField, DataSubjectField, DataStartField, DataEndField)?

Is there a way to get value ? Please let me know 

 

Thanks

Sabarish

SteadfastTechnology Services

www.steadfastglobal.com

0
Peter
Telerik team
answered on 30 Jul 2009, 11:59 AM
Hi sabarishbabu,

When OnClientAppointmentContextMenu is raised, use a hidden field to store the appointment id. Then, in the item click server side handler use FindByID to get the appointment object:

RadScheduler2.Appointments.FindByID(int.Parse(HiddenField1.Value));


Regards,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
sabarishbabu
Top achievements
Rank 1
answered on 30 Jul 2009, 02:05 PM

Hi Peter,

Thank you for your quick reply.

This is exactly what I am need. But, How can I get the selectedappointment Details (DataKeyField, DataSubjectField, DataStartField, DataEndField)?

Pleaselet me know

Thanks

Sabarish

SteadfastTechnology Services

www.steadfastglobal.com

HiPeter,

Thankyou for your idea. Your are great.

Iwas able to get the selected appointment id in Server side.

Mysample code here

<script type="text/javascript">

var selectedAppointment = null;

//Called when the user right-clicks an appointment

        function appointmentContextMenu(sender, eventArgs) {

                selectedAppointment =eventArgs.get_appointment();

                varmenu = $find('<%=SchedulerContextMenu.ClientID%>');

menu.show(eventArgs.get_domEvent());

              }

//Called when the user clicks an item from the appointment context menu

            functionappointmentContextMenuItemClicked(sender, eventArgs)

             {

                 //varapptId = selectedAppointment.get_id();

                 document.getElementById('hdnFileName').value =selectedAppointment.get_id();

                 sender.hide();

             }

         </script>




Thanks

Sabarish

Steadfast Technology Services

www.steadfastglobal.com

Tags
Scheduler
Asked by
sabarishbabu
Top achievements
Rank 1
Answers by
Peter
Telerik team
sabarishbabu
Top achievements
Rank 1
Share this question
or