Events class (Calendar)

Events(oCalendar)

new Events(oCalendar)

The Events object represents a collection of all events within the control, each of which is of the Event type. You can access this collection using the Calendar.Events method. This allows you to iterate through, add, remove, or modify individual events, enabling full management of the control's scheduled events and their properties. By working with the Events collection, you can efficiently handle multiple events, query specific dates, or apply batch updates to the calendar's event data. The Add, Count/GetCount, Item, Remove, and Clear methods provide a comprehensive API for managing the events within the calendar control.
Parameters:
Name Type Description
oCalendar Calendar Indicates an object of Calendar type that owns the collection.
Since:
  • 1.5

Members

(readonly) Count :number

The Count property returns the total number of events currently stored in the control's events collection. This allows you to determine how many events are scheduled, iterate through them programmatically, or perform operations such as validation, display, or reporting based on the collection size. It provides a simple way to track and manage all events within the calendar. The Add, Remove and Clear methods update the Count property accordingly.
Type:
  • number
Example
The following statements are equivalents:

 oCalendar.Event.GetCount(), counts the events within the control
 oCalendar.Event.Count, counts the events within the control

where oCalendar is an object of Calendar type
Count

Methods

Add(oEventOptsopt) → {Event}

The Add() method creates a new event and inserts it into the control's events collection. It allows you to specify the event's properties - such as date, title, tooltip, and repetition pattern - at the time of creation. By using this method, you can dynamically populate the calendar with events, schedule new occurrences, and ensure that each event is properly registered and displayed within the control.
Parameters:
Name Type Attributes Description
oEventOpts EventOptions <optional>
Specifies the options to create the new event as an object of EventOptions type.
Returns:
Returns the newly created event, as an object of Event type
Type
Event
Example
oCalendar.Events.Add("#1/1/2001#").Shape = "red", colorizes Jan 1st, 2001 on red
oCalendar.Events.Add({date: "#1/1/2001#", shape: "red"}), adds a new event on Jan 1st, 2001
Add

Clear()

The Clear() method removes all events of the control and inits the control's scroll-bars. By using this method, you can efficiently manage the events within the calendar, allowing you to delete all events at once. The Clear method updates the collection accordingly and ensures that any associated data or references are properly handled. The Count property is updated accordingly.

Item(id) → {null|Event}

The Item() method gets the event giving its index, identifier/key or reference. The Calendar.Event(id) method is an alias to this method. This method provides a flexible way to retrieve events from the collection, allowing you to access them by their position, unique identifier, or direct reference. By using this method, you can easily manage and manipulate specific events within the calendar based on various criteria.
Parameters:
Name Type Description
id any The id parameter could be any of the following:
  • id {number}, indicates a numeric value that defines the index of the event to request
  • id {string}, specifies a string expression that defines the identifier/key of the event to request
  • id {Event}, specifies the object reference to the event to request for
Returns:
Returns null if the event is not found, or an object of Event type, if the events collection contains the giving id.
Type
null | Event
Example
oCalendar.Event(0), gets the first event of the control
 oCalendar.Event("myEvent"), gets the event with "myEvent" identifier
Item

Remove(id)

The Remove() method removes an event from the collection. You can specify the event to remove by its index, unique identifier, or direct reference. By using this method, you can efficiently manage the events within the calendar, allowing you to delete specific events as needed. The Remove method updates the collection accordingly and ensures that any associated data or references are properly handled. The Event.Remove() method is an alias to this method, which allows you to remove an event directly from the event object itself.
Parameters:
Name Type Description
id any The id parameter could be any of the following:
  • id {number}, indicates a numeric value that defines the index of the event to request
  • id {string}, specifies a string expression that defines the identifier/key of the event to request
  • id {Event}, specifies the object reference to the event to request for
Example
oCalendar.Event.Remove(0), removes the first event of the control
oCalendar.Event.Remove("myEvent"), removes the event with "myEvent" identifier
Remove

RemoveRange(range) → {number}

The RemoveRange() method removes multiple-events at once. You can specify the events to remove by their indexes, unique identifiers, or direct references. By using this method, you can efficiently manage the events within the calendar, allowing you to delete specific events as needed. The RemoveRange method updates the collection accordingly and ensures that any associated data or references are properly handled.
Parameters:
Name Type Description
range any Indicates an event, an array [{Event}], or an exontrol.Arr([{Event}]).
Returns:
Returns the number of events being deleted
Type
number
Example
oCalendar.Events.RemoveRange([0,1,2]), removes the first three events of the control
 oCalendar.Events.RemoveRange(["myEvent1","myEvent2"]), removes the events with "myEvent1" and "myEvent2" identifiers
RemoveRange