Schedule Control: Customize "Save and Close" button function

Good day,

I am experimenting with this control and I would like to be able to modify the appointment details via a custom form. In particular I would like to change the drop down items from "Business", "Vaction", etc, to a status field with "Open", "Closed" and custom colors to match those types. Also, I would like to add a whole new field entirely ("Assigned to").

To accomplish this I have hidden the normal appointment menu and display a custom form (form2) instead. Now, however, I need to add code to my new "Save and Close" button to mimic what the normal button does but with these new changes. How do I go about saving the appointment from my custom form?

Thanks.

1 Reply

AA Arulraj A Syncfusion Team September 3, 2018 11:44 AM UTC

Hi Travis, 

Thanks for using Syncfusion products. 

To add the custom field for schedule appointment, you could implement the custom ArrayListDataProvider and ArrayListAppointment and override the NewSheduleAppointment method in custom ArrayListDataProvider. Please refer the following code example, 
Code example 
public class SimpleScheduleDataProvider : ArrayListDataProvider 
{ 
    /// <summary> 
    /// Default constructor. 
    /// </summary> 
    public SimpleScheduleDataProvider() 
        : base() 
    { 
    } 
 
   public override IScheduleAppointment NewScheduleAppointment() 
   { 
       return new SimpleScheduleAppointment(); 
   } 
} 
 
public class SimpleScheduleAppointment : ArrayListAppointment, ISerializable 
{ 
    /// <summary> 
    /// Default constructor. 
    /// </summary> 
    public SimpleScheduleAppointment() : base() 
    { 
    } 
 
    public bool AssignedTo { get; set; } 
} 

To display the custom form instead of default appointment form in ScheduleControl, you could handle the ShowingAppointmentForm event. Please refer to the below code example and the KB link, 
Code example 
Form2 form = new Form2(); 
this.scheduleControl1.ShowingAppointmentForm += scheduleControl1_ShowingAppointmentForm; 
 
void scheduleControl1_ShowingAppointmentForm(object sender, ShowingAppointmentEventArgs e) 
{ 
    //To get the current item. 
   form.Item = e.Item as SimpleScheduleAppointment; 

    //Cancel the default appointment form for schedule control. 
    e.Cancel = true; 
    //Shows the Custom appointment form. 
    form.ShowDialog(); 
} 



To add the appointment from custom appointment form in ScheduleControl. Please make use of the following code example and refer the following KB link, 
Code example 
void ok_Click(object sender, System.EventArgs e) 
{ 
        //Existing item 
        if (this.Item.UniqueID > -1) 
        { 
            this.DeleteRecurringAppointment(Item as IRecurringScheduleAppointment); 
            this.populateItem(this.Item); 
        } 
        else 
        { 
            SimpleScheduleAppointment item = DataProvider.NewScheduleAppointment() as SimpleScheduleAppointment; 
            this.populateItem(item); 
        } 
                
        this.schedulegrid.ResetProvider(this.schedulegrid.ScheduleType); 
        this.Close(); 
} 
 
private void populateItem(SimpleScheduleAppointment item) 
{ 
     if(item != null) 
     { 
          item.StartTime = this.StartDateDateTimePickerAdv.Value; 
          item.EndTime = this.EndDateDateTimePickerAdv.Value; 
          item.Subject = this.SubjectTextBoxExt.Text; 
          item.LabelValue = this.comboBox1.SelectedIndex; 
          item.AssignedTo = this.assignedTo.Checked; 
         //Appointment can be added in ScheduleDataProvider 
        DataProvider.AddItem(item); 
     } 
} 

 

Regards, 
Arulraj A 


Loader.
Up arrow icon