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

Update appointment occurrence programmatically

2 Answers 108 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 06 May 2012, 04:31 PM
Hello,
I have RadScheduler connected to sql server table provided by entity data source.
I want to be able to right click on an appointment or any occurrence and get a context menu that contains "Reserve" button.
Clicking "Reserve" will update a field in the related table.

I have customized the Appointment Context Menu as the following:

<AppointmentContextMenus>
                <telerik:RadSchedulerContextMenu runat="server" ID="ContextMenu1">
                    <Items>
                        <telerik:RadMenuItem Text="Edit" Value="CommandEdit" />
                        <telerik:RadMenuItem Text="Reserve" Value="Reserve" />
                    </Items>
                </telerik:RadSchedulerContextMenu>
</AppointmentContextMenus>

I handled the event of AppointmentContextMenuItemClicking

The question is: How could I update the appointment occurrence ?? taking into consideration that the occurrence doesn't has a record at the database table so I can update it. 

protected void RadScheduler1_AppointmentContextMenuItemClicking(object sender, Telerik.Web.UI.AppointmentContextMenuItemClickingEventArgs e)
   {
       if (e.MenuItem.Value == "Reserve")
       {
           // Code will go here
       }
   }


Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 09 May 2012, 01:42 PM
Hello,

You can use the server side API to create exception. Here is how:
protected void RadScheduler1_AppointmentContextMenuItemClicking(object sender, AppointmentContextMenuItemClickingEventArgs e)
   {
       if (e.MenuItem.Value == "Reserve")
       {
           // Code will go here
           Appointment a = RadScheduler1.Appointments.FindByID(e.Appointment.RecurrenceParentID);
           RecurrenceRule rRule = RecurrenceRule.TryParse(a.RecurrenceRule);
           rRule.Exceptions.Add(e.Appointment.Start);
           a.RecurrenceRule = rRule.ToString();
 
           Appointment exceptionAppointment = e.Appointment;
           exceptionAppointment.RecurrenceState = RecurrenceState.Exception;
           exceptionAppointment.Subject = "Reserved";
 
           RadScheduler1.InsertAppointment(exceptionAppointment);
           RadScheduler1.UpdateAppointment(a);
           RadScheduler1.Rebind();
       }
   }

Attached is a sample for reference.

Here is also a related help topic - Working with Recurring Appointments.

Regards,
Peter
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.
0
L
Top achievements
Rank 1
answered on 15 May 2012, 01:14 PM
Thanks Peter, Its working, I used to modify it a little to make it work with entity framework data source.
Tags
Scheduler
Asked by
L
Top achievements
Rank 1
Answers by
Peter
Telerik team
L
Top achievements
Rank 1
Share this question
or