Skip to main content

ISchedulerRecurrenceInfo.OccurrenceCount Property

Specifies how many times the recurrent appointment occurs.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

int OccurrenceCount { get; set; }

Property Value

Type Description
Int32

An integer value that specifies the number of occurrences.

Remarks

The recurrent appointment reoccurs during the period of time called range. The Start property specifies the range’s start date.

If the Range property is set to OccurrenceCount, the OccurrenceCount property defines the range’s end date (after recurrence count exceeds the specified value). In other cases, the OccurrenceCount value is ignored.

If the Range is set to EndByDate, the End property defines the range’s end date. If the Range is set to NoEndDate, the appointment repeats indefinitely.

The following example prevents users from creating reccurent appointments that occur only once:

<DxScheduler @bind-StartDate="@StartDate"
             DataStorage="@DataStorage"
             AppointmentUpdating="AppointmentUpdating"
             AppointmentInserting="AppointmentInserting"
             AppointmentFormClosing="AppointmentFormClosing">
    <DxSchedulerWeekView ShowWorkTimeOnly="true"></DxSchedulerWeekView>
</DxScheduler>
<DxPopup @bind-Visible="@AlertVisible"
         CloseOnEscape="true"
         CloseOnOutsideClick="true"
         ShowCloseButton="true"
         HeaderText="Note"
         BodyText="The recurrent appointment occurs only once. Increase the appointment count or create a regular appointment.">
</DxPopup>

@code {
    bool AlertVisible = false;
    bool ValidationFailed = false;
    DateTime StartDate { get; set; } = DateTime.Today;

    DxSchedulerDataStorage DataStorage = new DxSchedulerDataStorage() {
        AppointmentsSource = RecurringAppointmentCollection.GetAppointments(),
        AppointmentMappings = new DxSchedulerAppointmentMappings() {
            Type = "AppointmentType",
            Start = "StartDate",
            End = "EndDate",
            Subject = "Caption",
            AllDay = "AllDay",
            Location = "Location",
            Description = "Description",
            LabelId = "Label",
            StatusId = "Status",
            RecurrenceInfo = "Recurrence"
        }
    };
    bool IsAppointmentValid(DxSchedulerAppointmentItem appointment) {
        if (appointment.IsRecurring && 
                appointment.RecurrenceInfo.Range == SchedulerRecurrenceRange.OccurrenceCount &&
                appointment.RecurrenceInfo.OccurrenceCount == 1)
            return false;
        return true;
    }

    void AppointmentUpdating(SchedulerAppointmentOperationEventArgs e) {
        if (!IsAppointmentValid(e.Appointment)) {
            e.Cancel = true;
            AlertVisible = true;
            ValidationFailed = true;
        }
    }
    void AppointmentInserting(SchedulerAppointmentOperationEventArgs e) {
        if (!IsAppointmentValid(e.Appointment)) {
            e.Cancel = true;
            AlertVisible = true;
            ValidationFailed = true;
        }
    }
    void AppointmentFormClosing(SchedulerAppointmentFormClosingEventArgs e) {
        if (ValidationFailed) {
            e.Cancel = true;
            ValidationFailed = false;
        }
    }
}

See the DxSchedulerRecurrenceInfo class description for more information and an example.

See Also