- Description
- View Code
- Configuration (7)
- Methods (8)
- Events (2)
The Calendar widget allows to the end user to select a date from a graphical calendar. It supports custom templates for "month" view, configurable options for min and max date, start view and the depth of the navigation.
Getting Started
Creating a Calendar from existing DIV element
<!-- HTML -->
<div id="calendar"></div>Calendar initialization
$(document).ready(function(){
$("#calendar").kendoCalendar();
});When a Calendar is initialized, it will automatically be displayed near the location of the used HTML element.
Configuring Calendar behaviors
Calendar provides many configuration options that can be easily set during initialization. Among the properties that can be controlled:
- Selected date
- Minimum/Maximum date
- Start view
- Define the navigation depth (last view to which end user can navigate)
- Day template
- Footer template
Create Calendar with selected date and defined min and max date
$("#calendar").kendoCalendar({
value: new Date(),
min: new Date(1950, 0, 1),
max: new Date(2049, 11, 31)
});
<p>
Calendar will not navigate to dates less than min and bigger than max date.
</p>Define start view and navigation depth
The first rendered view can be defined with "startView" option. Navigation depth can be controlled with "depth" option. Predefined views are:
- "month" - shows the days from the month
- "year" - shows the months of the year
- "decade" - shows the years from the decade
- "century" - shows the decades from the century
Create Calendar, which allows to select month
$("#calendar").kendoCalendar({
startView: "year",
depth: "year"
});Customize day template
Calendar allows to customize content of the rendered day in the "month" view.
Create Calendar with custom template
$("#calendar").kendoCalendar({
month: {
content: '<div class="custom"><#=data.value#></div>'
}
});This templates wraps the "value" in a div HTML element. Here is an example of the object passed to the template function:
Structure of the data object passed to the template
data = {
date: date, // Date object corresponding to the current cell
title: kendo.toString(date, "D"),
value: date.getDate(),
dateString: toDateString(date) //Date formatted using "MM/dd/yyyy" format
};No code
-
max(value) : DateGets/Sets the max value of the calendar.Example
var calendar = $("#calendar").data("kendoCalendar"); // get the max value of the calendar. var max = calendar.max(); // set the max value of the calendar. calendar.max(new Date(2100, 0, 1));Parameters
-
value: Date|String - The max date to set.
- Returns
- Date The max value of the calendar.
-
-
min(value) : DateGets/Sets the min value of the calendar.Example
var calendar = $("#calendar").data("kendoCalendar"); // get the min value of the calendar. var min = calendar.min(); // set the min value of the calendar. calendar.min(new Date(1900, 0, 1));Parameters
-
value: Date|String - The min date to set.
- Returns
- Date The min value of the calendar.
-
-
navigate(value, viewName)Navigates to viewExample
calendar.navigate(value, view);Parameters
-
value: Date - Desired date
-
viewName: String - Desired view
-
-
navigateDown(value)Navigates to the lower viewExample
calendar.navigateDown(value);Parameters
-
value: Date - Desired date
-
-
Navigates to the future
Example
calendar.navigateToFuture(); -
Navigates to the past
Example
calendar.navigateToPast(); -
navigateUp()Navigates to the upper viewExample
calendar.navigateUp(); -
value(value) : DateGets/Sets the value of the calendar.Example
var calendar = $("#calendar").data("kendoCalendar"); // get the value of the calendar. var value = calendar.value(); // set the value of the calendar. calendar.value(new Date());Parameters
-
value: Date|String - The date to set.
- Returns
- Date The value of the calendar.
-