CalendarComponent
23 Sep 20256 minutes to read
Represents the Essential JS 2 Angular Calendar Component.
<ejs-calendar [value]='date'></ejs-calendar>Properties
calendarMode CalendarType
Gets or sets the Calendar’s Type like gregorian or islamic.
Defaults to Gregorian
cssClass string
Specifies the root CSS class of the Calendar that allows to
customize the appearance by overriding the styles.
Defaults to null
dayHeaderFormat DayHeaderFormats
Specifies the format of the day that to be displayed in header. By default, the format is ‘short’.
Possible formats are:
-
Short- Sets the short format of day name (like Su ) in day header. -
Narrow- Sets the single character of day name (like S ) in day header. -
Abbreviated- Sets the min format of day name (like Sun ) in day header. -
Wide- Sets the long format of day name (like Sunday ) in day header.
Defaults to Short
depth CalendarView
Sets the maximum level of view such as month, year, and decade in the Calendar.
Depth view should be smaller than the start view to restrict its view navigation.
Defaults to Month
enablePersistence boolean
Enable or disable persisting component’s state between page reloads. If enabled, following list of states will be persisted.
- value
Defaults to false
enableRtl boolean
Enable or disable rendering component in right to left direction.
Defaults to false
enabled boolean
Specifies the component to be disabled or not.
Defaults to true
firstDayOfWeek number
Gets or sets the Calendar’s first day of the week. By default, the first day of the week will be based on the current culture.
Defaults to 0
isMultiSelection boolean
Specifies the option to enable the multiple dates selection of the calendar.
Defaults to false
keyConfigs { : }
Customizes the key actions in Calendar.
For example, when using German keyboard, the key actions can be customized using these shortcuts.
|
Key action |
Key |
|
controlUp |
ctrl+38 |
|
controlDown |
ctrl+40 |
|
select |
enter |
|
home |
home |
|
end |
end |
|
pageUp |
pageup |
|
pageDown |
pagedown |
|
shiftPageUp |
shift+pageup |
|
shiftPageDown |
shift+pagedown |
|
controlHome |
ctrl+home |
|
controlEnd |
ctrl+end |
|
altUpArrow |
alt+uparrow |
|
spacebar |
space |
|
altRightArrow |
alt+rightarrow |
|
altLeftArrow |
alt+leftarrow |
|
moveDown |
downarrow |
|
moveUp |
uparrow |
|
moveLeft |
leftarrow |
|
moveRight |
rightarrow |
<ejs-calendar [keyConfigs]="keyConfigs"></ejs-calendar>import { Component, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-root',
styleUrls: ['app.component.css'],
templateUrl: 'app.component.html',
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
constructor() { }
public keyConfigs = {
select: "space",
home: "ctrl+home",
end: "ctrl+end"
}
}Defaults to null
locale string
Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.
Defaults to ’’
max Date
Gets or sets the maximum date that can be selected in the Calendar.
Defaults to new Date(2099, 11, 31)
min Date
Gets or sets the minimum date that can be selected in the Calendar.
Defaults to new Date(1900, 00, 01)
serverTimezoneOffset number
By default, the date value will be processed based on system time zone.
If you want to process the initial date value using server time zone
then specify the time zone value to serverTimezoneOffset property.
Defaults to null
showTodayButton boolean
Specifies whether the today button is to be displayed or not.
Defaults to true
start CalendarView
Specifies the initial view of the Calendar when it is opened.
With the help of this property, initial view can be changed to year or decade view.
Defaults to Month
value Date
Gets or sets the selected date of the Calendar.
Defaults to null
values Date[]
Gets or sets multiple selected dates of the calendar.
<ejs-calendar [values]="values" [isMultiSelection]="isMultiSelection"></ejs-calendar>import { Component, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-root',
styleUrls: ['app.component.css'],
templateUrl: 'app.component.html',
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
constructor() { }
public values = [new Date("11/20/2019"), new Date("11/28/2019"), new Date("11/2/2019")];
public isMultiSelection = true;
}Defaults to null
weekNumber boolean
Determines whether the week number of the year is to be displayed in the calendar or not.
Defaults to false
weekRule WeekRule
Specifies the rule for defining the first week of the year.
Defaults to FirstDay
Methods
addDate
This method is used to add the single or multiple dates to the values property of the Calendar.
| Parameter | Type | Description |
|---|---|---|
| dates |
Date | Date[]
|
Specifies the date or dates to be added to the values property of the Calendar. |
Returns void
currentView
Gets the current view of the Calendar.
Returns string
destroy
Destroys the widget.
Returns void
getPersistData
Gets the properties to be maintained upon browser refresh.
Returns string
navigateTo
This method is used to navigate to the month/year/decade view of the Calendar.
| Parameter | Type | Description |
|---|---|---|
| view | CalendarView |
Specifies the view of the Calendar. |
| date | Date |
Specifies the focused date in a view. |
| isCustomDate (optional) | boolean |
Specifies whether the calendar is rendered with custom today date or not. |
Returns void
removeDate
This method is used to remove the single or multiple dates from the values property of the Calendar.
| Parameter | Type | Description |
|---|---|---|
| dates |
Date | Date[]
|
Specifies the date or dates which need to be removed from the values property of the Calendar. |
Returns void
Events
change EmitType<ChangedEventArgs>
Triggers when the Calendar value is changed.
created EmitType<Object>
Triggers when Calendar is created.
destroyed EmitType<Object>
Triggers when Calendar is destroyed.
navigated EmitType<NavigatedEventArgs>
Triggers when the Calendar is navigated to another level or within the same level of view.
renderDayCell EmitType<RenderDayCellEventArgs>
Triggers when each day cell of the Calendar is rendered.