Back to Devexpress

DxScheduler.ValidateEditForm Property

blazor-devexpress-dot-blazor-dot-dxscheduler-40333760.md

latest3.9 KB
Original Source

DxScheduler.ValidateEditForm Property

Specifies whether to validate the appointment edit form.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(false)]
[Parameter]
public bool ValidateEditForm { get; set; }

Property Value

TypeDefaultDescription
Booleanfalse

true to validate the appointment edit form; otherwise, false.

|

Remarks

The edit form appears when you create or edit an appointment. Follow the steps below to enable appointment form validation:

  1. Set the ValidateEditForm property to true.
  2. Implement a SchedulerAppointmentFormInfo class descendant and mark appointment properties with data annotation attributes.
  3. Handle the AppointmentFormShowing event and assign a custom descendant instance to the event argument’s FormInfo property.
  4. (Optionally) Use AppointmentFormLayout and AppointmentCompactFormLayout properties to create custom edit forms. Add the DxSchedulerCustomFormLayoutItem to the form layout and use the ValidationSummary component in the item template to display validation messages.
razor
<DxScheduler StartDate="@DateTime.Today"
             DataStorage="@DataStorage"
             ActiveViewType="SchedulerViewType.WorkWeek"
             AppointmentFormShowing="OnAppointmentFormShowing"
             ValidateEditForm="true">
    @*...*@
    <AppointmentCompactFormLayout>
        @*...*@
        <DxSchedulerCustomFormLayoutItem ColSpanMd="12">
            <Template>
                <ValidationSummary />
            </Template>
        </DxSchedulerCustomFormLayoutItem>
    </AppointmentCompactFormLayout>
</DxScheduler>

@code {
    DxScheduler scheduler { get; set; }

    public class CustomAppointmentFormInfo : SchedulerAppointmentFormInfo {
        public CustomAppointmentFormInfo(DxSchedulerAppointmentItem AppointmentItem, 
                DxSchedulerDataStorage DataStorage, DxScheduler scheduler) : base(AppointmentItem, DataStorage, scheduler) { }

        [Required]
        public override string Subject {
            get { return base.Subject; }
            set { base.Subject = value; }
        }
        // ...
    }

    void OnAppointmentFormShowing(SchedulerAppointmentFormEventArgs args) {
        args.FormInfo = new CustomAppointmentFormInfo(args.Appointment, DataStorage, scheduler);
    }
    // ...
}

Run Demo: Scheduler - Custom Fields and Appointment Form

YouTube video

See Also

DxScheduler Class

DxScheduler Members

DevExpress.Blazor Namespace