title | page_title | description |
---|---|---|
Calendar |
Configuration, methods and events of Kendo UI Calendar |
Find out how to successfully configure calendar UI component, how to use methods to get the max value of the calendar and navigate easily. |
Represents the Kendo UI Calendar widget. Inherits from Widget.
Specifies the culture info used by the widget.
<!--
TODO: Add the kendo.culture.de-DE.min.js file as it is required!
Here is a sample script tag:
<script src="http://kendo.cdn.telerik.com/{kendo version}/js/cultures/kendo.culture.de-DE.min.js"></script>
For more information check this help topic:
http://docs.telerik.com/kendo-ui/framework/globalization/overview
-->
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
culture: "de-DE"
});
</script>
Specifies a list of dates, which will be passed to the month template.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
value: new Date(2000, 10, 1),
dates: [
new Date(2000, 10, 10, 10, 0, 0),
new Date(2000, 10, 10, 30, 0)
] //can manipulate month template depending on this array.
});
</script>
Specifies the navigation depth. The following settings are available for the depth value:
shows the days of the month
shows the months of the year
shows the years of the decade
shows the decades from the century
Note the option will not be applied if start option is lower than depth. Always set both and start and depth options.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
depth: "year"
});
</script>
The template which renders the footer. If false, the footer will not be rendered.
<div id="calendar"></div>
<script id="footer-template" type="text/x-kendo-template">
Today - #: kendo.toString(data, "d") #
</script>
<script>
$("#calendar").kendoCalendar({
footer: kendo.template($("#footer-template").html())
});
</script>
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
footer: "Today - #: kendo.toString(data, 'd') #"
});
</script>
Specifies the format, which is used to parse value set with value() method.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
format: "yyyy/MM/dd"
});
</script>
Specifies the maximum date, which the calendar can show.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
max: new Date(2013, 0, 1) // set the max date to Jan 1st, 2013
});
</script>
Specifies the minimum date, which the calendar can show.
<div id="calendar"></div>
<script>
// set the min date to Jan 1st, 2011
$("#calendar").kendoCalendar({
min: new Date(2011, 0, 1)
});
</script>
Templates for the cells rendered in "month" view.
The template to be used for rendering the cells in "month" view, which are between the min/max range. By default, the widget renders the value of the corresponding day.
<div id="calendar"></div>
<script id="cell-template" type="text/x-kendo-template">
<div class="#= data.value < 10 ? 'exhibition' : 'party' #"></div>
#= data.value #
</script>
<script>
$("#calendar").kendoCalendar({
month: {
content: $("#cell-template").html()
}
});
</script>
The template to be used for rendering the cells in the "month" view, which are not in the min/max range. By default, the widget renders an empty string.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
month: {
empty: '-'
}
});
</script>
Specifies the start view. The following settings are available for the start value:
shows the days of the month
shows the months of the year
shows the years of the decade
shows the decades from the century
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
start: "year"
});
</script>
Specifies the selected date.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
value: new Date(2012, 0, 1)
});
</script>
Gets currently focused date.
Date
The current focused date shown in the calendar.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
var current = calendar.current(); //will be today, because value is `null`
</script>
Prepares the Calendar for safe removal from DOM. Detaches all event handlers and removes jQuery.data attributes to avoid memory leaks. Calls destroy method of any child Kendo widgets.
Important: This method does not remove the Calendar element from DOM.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
calendar.destroy();
</script>
Gets/Sets the max value of the calendar.
The max date to set.
Date
The max value of the calendar.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
var max = calendar.max();
</script>
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
calendar.max(new Date(2100, 0, 1));
</script>
Gets/Sets the min value of the calendar.
The min date to set.
Date
The min value of the calendar.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
var min = calendar.min();
</script>
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
calendar.min(new Date(1900, 0, 1));
</script>
Navigates to view.
Desired date.
Desired view.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
calendar.navigate(new Date(2012, 0, 1), "year");
</script>
Navigates to the lower view.
Desired date.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
calendar.navigateDown(new Date(2012, 0, 1));
</script>
Navigates to the future.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
calendar.navigateToFuture();
</script>
Navigates to the past.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
calendar.navigateToPast();
</script>
Navigates to the upper view.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
calendar.navigateUp();
</script>
Gets/Sets the value of the calendar.
The date to set.
Date
The value of the calendar.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
value: new Date(2013, 10, 10)
});
var calendar = $("#calendar").data("kendoCalendar");
var value = calendar.value();
</script>
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
value: new Date(2013, 10, 10)
});
var calendar = $("#calendar").data("kendoCalendar");
calendar.value(new Date());
</script>
Gets an instance of the current view used by the calendar.
Object
The instance of the current view used by the calendar.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
var view = calendar.view();
</script>
Fires when the selected date is changed.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
change: function() {
var value = this.value();
console.log(value); //value is the selected date in the calendar
}
});
</script>
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
calendar.bind("change", function() {
var value = this.value();
console.log(value); //value is the selected date in the calendar
});
</script>
Fires when calendar navigates.
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar({
navigate: function() {
var view = this.view();
console.log(view.name); //name of the current view
var current = this.current();
console.log(current); //currently focused date
}
});
</script>
<div id="calendar"></div>
<script>
$("#calendar").kendoCalendar();
var calendar = $("#calendar").data("kendoCalendar");
calendar.bind("navigate", function() {
var view = this.view();
console.log(view.name); //name of the current view
var current = this.current();
console.log(current); //currently focused date
});
</script>