-
Data Grid
- Overview
-
Data Binding
-
Paging and Scrolling
-
Editing
-
Grouping
-
Filtering and Sorting
- Focused Row
-
Row Drag & Drop
-
Selection
-
Columns
- State Persistence
-
Appearance
-
Templates
-
Data Summaries
-
Master-Detail
-
Export to PDF
-
Export to Excel
-
Adaptability
- Keyboard Navigation
-
Pivot Grid
- Overview
-
Data Binding
-
Field Chooser
-
Features
-
Export to Excel
-
Tree List
- Overview
-
Data Binding
- Sorting
- Paging
-
Editing
- Node Drag & Drop
- Focused Row
-
Selection
-
Filtering
-
Column Customization
- State Persistence
- Adaptability
- Keyboard Navigation
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Features
- Virtual Scrolling
-
Grouping
-
Customization
- Adaptability
-
Html Editor
-
Chat
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
Charts
- Overview
-
Data Binding
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Line Charts
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
-
Sparkline Charts
-
Tree Map
-
Funnel and Pyramid Charts
- Sankey Chart
-
Combinations
-
More Features
-
Export
-
Selection
-
Tooltips
-
Zooming
-
-
Gantt
- Overview
-
Data
-
UI Customization
- Strip Lines
- Export to PDF
- Sorting
-
Filtering
-
Reporting
- AI-powered Extensions
-
Interaction
-
Report Types
-
Data binding
-
Real-life Reports
-
Layout Features
-
Report Controls
-
Web-specific Features
-
Rich Text Editor
- Overview
- Load/Save
- Document Protection
-
Templates
- Autocorrect
-
Customization
- Simple View
-
Spreadsheet
- Overview
-
Open a Document
- Export And Printing
-
Features
-
UI Customization
-
Gauges
- Overview
-
Data Binding
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Navigation
- Overview
- Accordion
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
- Pagination
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Resizable
-
-
Editors
- Overview
- Autocomplete
-
Calendar
- Check Box
- Color Box
- Date Box
-
Date Range Box
-
Drop Down Box
-
Number Box
-
Select Box
- Switch
-
Tag Box
- Text Area
- Text Box
- Validation
- Custom Text Editor Buttons
- Right-to-Left Support
- Editor Appearance Variants
-
Forms and Multi-Purpose
- Overview
- Button Group
- Field Set
-
Filter Builder
-
Form
- Radio Group
-
Range Selector
- Numeric Scale (Lightweight)
- Numeric Scale
- Date-Time Scale (Lightweight)
- Date-Time Scale
- Logarithmic Scale
- Discrete scale
- Custom Formatting
- Use Range Selection for Calculation
- Use Range Selection for Filtering
- Image on Background
- Chart on Background
- Customized Chart on Background
- Chart on Background with Series Template
- Range Slider
- Slider
-
Sortable
-
File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Actions and Lists
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
Calendar - Overview
This demo shows how to use additional properties to customize your Calendar. You can toggle the checkboxes on the right to change the Calendar in real time.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
@{
var zoomLevels = new[] { "month", "year", "decade", "century" };
var weekNumberRules = new[] { "auto", "firstDay", "firstFourDays", "fullWeek" };
var weekDays = new[] {
new { Id = 0, Text = "Sunday" },
new { Id = 1, Text = "Monday" },
new { Id = 2, Text = "Tuesday" },
new { Id = 3, Text = "Wednesday" },
new { Id = 4, Text = "Thursday" },
new { Id = 5, Text = "Friday" },
new { Id = 6, Text = "Saturday" },
};
}
<div id="calendar-demo">
<div class="calendar-container">
@(Html.DevExtreme().Calendar()
.ID("calendar-container")
.Value(DateTime.Now)
.Disabled(false)
.FirstDayOfWeek(FirstDayOfWeek.Sunday)
.ZoomLevel(CalendarZoomLevel.Month)
.OnValueChanged("calendar_valueChanged")
.OnOptionChanged("calendar_optionChanged")
)
</div>
<div class="options">
<div class="caption">Options</div>
<div class="option">
<span>Zoom level</span>
@(Html.DevExtreme().SelectBox()
.ID("zoom-level")
.InputAttr("aria-label", "Zoom Level")
.DataSource(zoomLevels)
.Value(zoomLevels[0])
.OnValueChanged("zoomLevel_changed")
)
</div>
<div class="option">
<span>Selected date</span>
@(Html.DevExtreme().DateBox()
.InputAttr("aria-label", "Date")
.ID("selected-date")
.Value(DateTime.Now)
.OnValueChanged("selectedDate_changed")
)
</div>
<div class="option">
@(Html.DevExtreme().CheckBox()
.Text("Use custom cell template")
.Value(false)
.OnValueChanged("useCustomTemplate")
)
</div>
<div class="option">
@(Html.DevExtreme().CheckBox()
.Text("Disable the calendar")
.OnValueChanged("disabledState_changed")
)
</div>
<div class="caption option">
<span>Week numeration</span>
</div>
<div class="option">
@(Html.DevExtreme().CheckBox()
.Text("Show week numbers")
.OnValueChanged("showWeekNumbers_changed")
)
</div>
<div class="option">
<span>First day of week</span>
@(Html.DevExtreme().SelectBox()
.DataSource(weekDays)
.Value(FirstDayOfWeek.Sunday)
.InputAttr("aria-label", "First Day of Week")
.ValueExpr("Id")
.DisplayExpr("Text")
.OnValueChanged("firstDayOfWeek_changed")
)
</div>
<div class="option">
<span>Week number rule</span>
@(Html.DevExtreme().SelectBox()
.DataSource(weekNumberRules)
.Value(WeekNumberRule.Auto)
.InputAttr("aria-label", "Week Number Rule")
.OnValueChanged("weekNumberRule_changed")
)
</div>
</div>
</div>
<script>
var date = new Date().getTime();
function getCalendarInstance() {
return $("#calendar-container").dxCalendar("instance");
}
function getDateBoxInstance() {
return $("#selected-date").dxDateBox("instance");
}
function isWeekend(date) {
var day = date.getDay();
return day === 0 || day === 6;
}
function getCellTemplate(data) {
var cssClass = "";
if (data.view === 'month') {
if (!data.date) {
cssClass = "week-number";
} else {
if (isWeekend(data.date))
cssClass = "weekend";
$.each([[1, 0], [4, 6], [25, 11]], function (_, item) {
if(data.date.getDate() === item[0] && data.date.getMonth() === item[1]) {
cssClass = "holiday";
return false;
}
});
}
}
return "<span class='" + cssClass + "'>" + data.text + "</span>";
}
function calendar_valueChanged(data) {
getDateBoxInstance().option("value", data.value);
}
function calendar_optionChanged(data) {
if (data.name === 'zoomLevel') {
$("#zoom-level").dxSelectBox("instance").option('value', data.value);
}
}
function firstDayOfWeek_changed(data) {
getCalendarInstance().option("firstDayOfWeek", data.value);
}
function weekNumberRule_changed(data) {
getCalendarInstance().option("weekNumberRule", data.value);
}
function showWeekNumbers_changed(data) {
getCalendarInstance().option("showWeekNumbers", data.value);
}
function useCustomTemplate(data) {
getCalendarInstance().option("cellTemplate", data.value ? getCellTemplate : "cell");
}
function disabledState_changed(data) {
getCalendarInstance().option("disabled", data.value);
}
function zoomLevel_changed(data) {
getCalendarInstance().option("zoomLevel", data.value);
}
function selectedDate_changed(data) {
getCalendarInstance().option("value", data.value);
}
</script>
xxxxxxxxxx
xxxxxxxxxx
When you add a Calendar to an application, you need to specify its value in one of the following formats:
-
Date
Specifies the date directly. -
Number
Specifies the date with a timestamp (total milliseconds since 1970/01/01). -
String
Specifies the date with a string value. The UI component supports the following formats of a date string:- "yyyy-MM-dd" (for example, "2017-03-06")
- "yyyy-MM-ddTHH:mm:ss" (for example, "2017-03-27T16:54:48")
- "yyyy-MM-ddTHH:mm:ssZ" (for example, "2017-03-27T13:55:41Z")
- "yyyy-MM-ddTHH:mm:ssx" (for example, "2017-03-27T16:54:10+03")
-
Array of the formats mentioned before
Available only for 'multiple' and 'range' selection modes. The array includes all selected dates.
Specify First Day of Week and Display Week Numbers
To specify the first day of the week, assign its index (0 - for Sunday, 1 - for Monday, and so on) to the firstDayOfWeek property. You can also display a column with week numbers. For this, enable the showWeekNumbers property.
The start of the first week of the year depends on the locale. If you want to apply a specific rule, use the weekNumberRule property.
Handle Value Change
Set the onValueChanged property to handle the value change. In this demo, the DateBox and the Calendar both use this property to pass values between each other, and you can use one of these components to change the date.
Customize Cell Appearance
Use the cellTemplate property to customize cell appearance. In this demo, the following customizations are applied when you toggle the "Use custom cell template" checkbox:
-
All the weekends on the Calendar become blue.
-
All the holidays become red.
-
If a column with week numbers is shown, week numbers are italicized.
You can set your own function that changes the class of the span element that contains cell text.
Other Customizations
Set the disabled property to disable the Calendar.
To specify the initial calendar view (month, year, decade, or century), set the zoomLevel property.