Skip to content

Use the SetAppointmentFormTemplateContent method to create a custom appointment form.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/asp-net-mvc-scheduler-custom-appointment-form

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scheduler for ASP.NET MVC - How to implement a custom edit appointment form

This example demonstrates how to use the SetAppointmentFormTemplateContent method to create a custom appointment form.

Overview

Call the control's MVCxSchedulerOptionsForms.SetAppointmentFormTemplateContent method to add a custom appointment form to the SchedulerPartial view.

settings.OptionsForms.SetAppointmentFormTemplateContent(c => {
    var container = (CustomAppointmentTemplateContainer)c;
    var schedule = ViewData["EditableSchedule"] != null
        ? (Schedule)ViewData["EditableSchedule"]
        : new Schedule() {
            ID = container.Appointment.Id == null ? -1 : (int)container.Appointment.Id,
            <!-- ... -->
        };
    
    ViewBag.DeleteButtonEnabled = container.CanDeleteAppointment;
    ViewBag.IsRecurring = container.Appointment.IsRecurring;
    ViewBag.AppointmentRecurrenceFormSettings = CreateAppointmentRecurrenceFormSettings(container);

    ViewBag.ResourceDataSource = container.ResourceDataSource;
    ViewBag.StatusDataSource = container.StatusDataSource;
    ViewBag.LabelDataSource = container.LabelDataSource;
    ViewBag.ReminderDataSource = container.ReminderDataSource;

    Html.RenderPartial("CustomAppointmentFormPartial", schedule);
});

Create an AppointmentFormTemplateContainer to add custom fields to your appointment form and handle the control's server-side ASPxScheduler.AppointmentFormShowing event to replace the default container with the custom container.

settings.AppointmentFormShowing = (sender, e) => {
    var scheduler = sender as MVCxScheduler;
    if (scheduler != null)
        e.Container = new CustomAppointmentTemplateContainer(scheduler);
};

Files to Review

Documentation

More Examples