Zum Hauptinhalt springen

cancelCalendarChanges

The cancelCalendarChanges function reverts any changes made to a calendar event when users drag, resize or edit events in a FullCalendar control. This function must be called from within an OnEventChange event handler to have effect. It serves as a rejection mechanism when calendar event changes should not be applied due to validation rules or business constraints.

Syntax

app.cancelCalendarChanges(controlId)

Parameters

ParameterTypeDescription
controlIdstringThe ID of the FullCalendar control whose event changes should be canceled

Return Value

None

Description

When a user drags, resizes or edits an event in a FullCalendar control, an OnEventChange event is triggered. Within the event handler for this event, you can implement validation logic to determine if the change is allowed. If the change should be rejected, calling cancelCalendarChanges() will revert the calendar to its previous state, moving all affected events back to their original positions and restoring their original properties.

This is particularly useful when:

  • The user attempts to move an event to a date/time that conflicts with business rules
  • The user tries to resize an event to a duration that is not allowed
  • The event change would create a scheduling conflict

Example

// This code is placed in an OnEventChange event handler
const eventId = eventArgs.id;
const newStart = eventArgs.start;
const newEnd = eventArgs.end;

// Check if the change should be rejected
if (!isValidDateRange(newStart, newEnd)) {
// Show an error message to the user
app.showInfoMessage("Invalid Date Range", "The selected time slot is not available.", 5000, null, "danger");

// Cancel the changes and revert the calendar to its previous state
app.cancelCalendarChanges("calendarControl");
return;
}

// If we get here, the change is allowed, and the calendar will keep the change

See Also