Update appointment occurrence programmatically

3 posts, 1 answers
  1. L
    L avatar
    2 posts
    Member since:
    May 2012

    Posted 06 May 2012 Link to this post

    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. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 09 May 2012 Link to this post

    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.
  3. L
    L avatar
    2 posts
    Member since:
    May 2012

    Posted 15 May 2012 Link to this post

    Thanks Peter, Its working, I used to modify it a little to make it work with entity framework data source.
Back to Top