DevExtreme v24.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

Multiple Selection

This demo applies different selection modes and date availability options to the Calendar component.

Backend API
$(() => { const msInDay = 1000 * 60 * 60 * 24; const selectionModes = ['single', 'multiple', 'range']; const date = new Date().getTime(); const calendar = $('#calendar').dxCalendar({ value: [date, date + msInDay], showWeekNumbers: true, selectWeekOnClick: true, selectionMode: 'multiple', }).dxCalendar('instance'); $('#select-week').dxCheckBox({ text: 'Select week on click', value: true, onValueChanged(data) { calendar.option('selectWeekOnClick', data.value); }, }); $('#selection-mode').dxSelectBox({ dataSource: selectionModes, value: selectionModes[1], inputAttr: { 'aria-label': 'Selection Mode' }, onValueChanged(data) { calendar.option('selectionMode', data.value); }, }).dxSelectBox('instance'); $('#min-date').dxCheckBox({ text: 'Set minimum date', onValueChanged(data) { const minDate = new Date(date - msInDay * 3); calendar.option('min', data.value ? minDate : null); }, }); $('#max-date').dxCheckBox({ text: 'Set maximum date', onValueChanged(data) { const maxDate = new Date(date + msInDay * 3); calendar.option('max', data.value ? maxDate : null); }, }); $('#disable-dates').dxCheckBox({ text: 'Disable weekends', onValueChanged(data) { if (data.value) { calendar.option('disabledDates', (d) => d.view === 'month' && isWeekend(d.date)); } else { calendar.option('disabledDates', null); } }, }); $('#clear-button').dxButton({ text: 'Clear value', onClick: () => { calendar.clear(); }, }); function isWeekend(d) { const day = d.getDay(); return day === 0 || day === 6; } });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/24.1.3/css/dx.light.css" /> <script src="js/dx.all.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container" id="calendar-demo"> <div class="calendar-container"> <div id="calendar"></div> </div> <div class="options"> <div class="caption">Options</div> <div class="option"> <div id="select-week"></div> </div> <div class="option"> <span>Selection mode</span> <div id="selection-mode"></div> </div> <div class="caption option"> <span>Date availability</span> </div> <div class="option"> <div id="min-date"></div> </div> <div class="option"> <div id="max-date"></div> </div> <div class="option"> <div id="disable-dates"></div> </div> <div class="option"> <div id="clear-button"></div> </div> </div> </div> </body> </html>
#calendar-demo { display: flex; } .calendar-container { display: flex; flex-direction: column; flex-grow: 1; align-items: center; justify-content: center; } .caption { font-weight: 500; font-size: 18px; } .options { padding: 20px; background-color: rgba(191, 191, 191, 0.15); } .option { margin-top: 10px; }

Selection Modes

The selected value or values are stored in the value property. The following selection modes are available:

  • 'single'
    A user can select only a single date at any given time.

  • 'multiple'
    A user can select multiple dates simultaneously.

  • 'range'
    A user can select a range of dates. The first and the last date in the range are stored in the value property.

If you enable selectWeekOnClick in 'multiple' or 'range' modes, users can select a week by clicking on the week number.

Disable and Clear Dates

Use the min and max properties to specify the range of available dates. In this demo, these properties limit the range to three days before and after the current date. Enable the "Set minimum date" and "Set maximum date" checkboxes to apply the properties.

If you need to disable specific dates, use the disabledDates property. Toggle the "Disable weekends" checkbox to see how this setting affects component behavior. You can specify either an array of predefined dates or a function that determines whether a date is available.

When using 'multiple' and 'range' selection modes, the behavior of disabled dates in the Calendar is as follows:

  • If you specify the value property programmatically, disabled dates are selected in the values array.

  • If you use the UI to change selection (click on dates or weeks, the Enter key), you cannot select disabled dates in 'multiple' mode. In 'range' mode, disabled dates cannot start or end a range, but can be included in the middle.

To clear selected values, call the Calendar clear() method.