DateRangePicker
in namespace DotVVM.BusinessPack.Controls
Usage & Scenarios
Lets the user select a start date and an end date, either in a drop-down editor or in calendars displayed directly on the page.
Sample 1: Selecting a travel period
Bind SelectedStartDate and SelectedEndDate to separate nullable DateTime properties. StartDatePlaceholder and EndDatePlaceholder identify the inputs before the user selects dates. Both the editor and the inline calendars below update the same period.
MinDate and MaxDate define the booking window. The inline view starts each week on Monday and shows week numbers; the Changed command counts edits in either view.
<bp:DateRangePicker SelectedStartDate="{value: Departure}" SelectedEndDate="{value: ReturnDate}"
StartDatePlaceholder="Departure" EndDatePlaceholder="Return"
MinDate="{value: Today}" MaxDate="{value: LastBookingDate}" AllowUnselect="true"
FormatString="dd MMM yyyy" Changed="{command: Changes = Changes + 1}" />
<bp:DateRangePicker ShowInline="true" FirstDayOfWeek="Monday" WeekNumberMode="FirstFourDayWeek"
MinDate="{value: Today}" MaxDate="{value: LastBookingDate}"
SelectedStartDate="{value: Departure}" SelectedEndDate="{value: ReturnDate}"
Changed="{command: Changes = Changes + 1}" />
<p>Changes: {{value: Changes}}</p>
using System;
using DotVVM.Framework.ViewModel;
namespace DotvvmWeb.Views.Docs.Controls.businesspack.DateRangePicker.sample1
{
public class ViewModel : DotvvmViewModelBase
{
public DateTime Today => DateTime.Today;
public DateTime LastBookingDate => Today.AddMonths(6);
public int Changes { get; set; }
public DateTime? Departure { get; set; }
public DateTime? ReturnDate { get; set; }
}
}
Properties
| Name | Type | Description | Notes | Default Value | |
|---|---|---|---|---|---|
| AllowUnselect | Boolean | Gets or sets whether the selected value can be unselected. It is allowed by default. |
attribute
static value
bindable
|
True | |
| AutoFocus | Boolean | Gets or sets whether the control should have focus when page loads or when a dialog is opened. The default value is false. |
attribute
static value
|
False | |
| ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
Static | |
| ConfirmIcon | IconBase | Gets or sets the icon to confirm selection and close popup dialog. |
inner element
static value
bindable
|
null | |
| DataContext | Object | Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value. The DataContext is null in client-side templates. |
attribute
bindable
|
null | |
| Enabled | Boolean | Gets or sets whether the control is enabled and can be modified. |
attribute
static value
bindable
|
True | |
| EndDatePlaceholder | String | Gets or sets the text displayed when end date is not selected. |
attribute
static value
|
null | |
| FirstDayOfWeek | DayOfWeek? | Gets or sets the first day of a week. Set the value to Monday if you want to display ISO 8601 weeks. The default value is based on the current culture. |
attribute
static value
|
null | |
| FormatString | String | Gets or sets the format string that will be used to display the value. |
attribute
static value
|
null | |
| ID | String | Gets or sets the control client ID within its naming container. |
attribute
static value
bindable
|
null | |
| IncludeInPage | Boolean | Gets or sets whether the control is included in the DOM of the page. |
attribute
static value
bindable
|
True | |
| MaxDate | DateTime? | Gets or sets the highest date that can be selected by user. |
attribute
bindable
|
null | |
| MinDate | DateTime? | Gets or sets the lowest date that can be selected by user. |
attribute
bindable
|
null | |
| NextIcon | IconBase | Gets or sets the icon displayed on the button navigating to next page. |
inner element
static value
bindable
|
null | |
| Placeholder | String | Gets or sets the text displayed when value is not selected. |
attribute
static value
bindable
|
null | |
| PrevIcon | IconBase | Gets or sets the icon displayed on the button navigating to previous page. |
inner element
static value
bindable
|
null | |
| Restrictions | IEnumerable<DateRestriction> | Gets or sets a collection of rules specifying which date intervals can't be selected. |
attribute
bindable
|
null | |
| SelectedEndDate | DateTime? | Gets or sets the end date selected by user. |
attribute
bindable
|
null | |
| SelectedStartDate | DateTime? | Gets or sets the start date selected by user. |
attribute
bindable
|
null | |
| ShowInline | Boolean | Gets or sets whether the picker is displayed inline in page or as a drop-down editor. |
attribute
static value
|
False | |
| StartDatePlaceholder | String | Gets or sets the text displayed when start date is not selected. |
attribute
static value
|
null | |
| TabIndex | Int32 | Gets or sets the order in which the control is reachable in sequential keyboard navigation. The default value is 0 which means the document order. |
attribute
static value
bindable
|
0 | |
| ToggleIcon | IconBase | Gets or sets the icon displayed on the toggle button. |
inner element
static value
bindable
|
null | |
| UnselectIcon | IconBase | Gets or sets the icon displayed on the unselect button. |
inner element
static value
bindable
|
null | |
| UseFormatStringAsPlaceholder | Boolean | Gets or sets whether to use the FormatString as a placeholder when placeholder property is not set. It is enabled by default. |
attribute
static value
|
True | |
| Visible | Boolean |
attribute
bindable
|
True | ||
| WeekNumberMode | WeekNumberMode | Gets or sets how are week numbers computed and whether to display them. The default value is Disabled. |
attribute
static value
|
Disabled |
Events
| Name | Type | Description | |
|---|---|---|---|
| Changed | Command | Gets or sets the command triggered when the value is changed. |