Class sap.m.DateRangeSelectionModule: sap/m/DateRangeSelection
This is a date range input control with a calendar as date picker.
A date range can be entered using a calendar that opens in a popup. Alternatively a value can be entered directly in the input field by typing it in. (This is only possible on desktop devices, on mobile devices keyboard input is not possible.) If a date range is entered by typing it into the input field, it must fit to the used date format and locale. (See sap.ui.core.format.DateFormat
)
There are two options to provide a date for the DateRangeSelection
. You can put a date range as a string to the property value
or you can put JavaScript Date objects to the properties dateValue
and secondDateValue
. Only one of the properties should be used at one time, but they are synchronized internally. What property to use depends on the use case of the application.
- Use the
value
property if the date range is already provided as a formatted string. - Use the
dateValue
andsecondDateValue
properties if the date range is already provided as JavaScript Date objects or you want to work with JavaScript Date objects.
All formatting and parsing of dates from and to strings is done using the sap.ui.core.format.DateFormat, so read the corresponding documentation if you need some information about this.
Supported format options are pattern-based on Unicode LDML Date Format notation. http://unicode.org/reports/tr35/#Date_Field_Symbol_Table
For example, if the displayFormat
is "MMM d, y", delimiter
is "-" and the used locale is English, a valid value
string is "Jul 29, 2015 - Jul 31, 2015" and it will be displayed in the same way in the input field.
If no placeholder
is set to the DatePicker
the used displayFormat
is shown as placeholder. If another placeholder is needed, it must be set.
Internally the sap.ui.unified.Calendar
is used, but it is only needed if the DateRangeSelection
is opened. This means that it is not needed for the initial rendering. If the sap.ui.unified
library is not loaded before the DateRangeSelection
is opened, it will be loaded upon opening. This could lead to a waiting time before a DateRangeSelection
is opened the first time. To prevent this, applications using the DateRangeSelection
should also load the sap.ui.unified
library.
Since: 1.22.0.
sClassName
and enriches it with the information contained in oClassInfo
. Accepts an object literal mSettings
that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.
The supported settings are:
- Properties
- delimiter : string (default: -)
- secondDateValue : object
- from : object
- to : object
In addition, all settings applicable to the base type sap.m.DatePicker can be used as well.
{string} | sId? | Id for the new control, generated automatically if no id is given |
{object} | mSettings? | Initial settings for the new control |
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters | |
{string} | oControlEvent.getParameters.value | The new value of the sap.m.DateRangeSelection . |
{boolean} | oControlEvent.getParameters.valid | Indicator for a valid date. |
{object} | oControlEvent.getParameters.from | Current start date after change. |
{object} | oControlEvent.getParameters.to | Current end date after change. |
sClassName
and enriches it with the information contained in oClassInfo
. oClassInfo
might contain the same kind of information as described in sap.m.DatePicker.extend.
{string} | sClassName | Name of the class being created |
{object} | oClassInfo? | Object literal with information about the class |
{function} | FNMetaImpl? | Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata |
{function} | Created class / constructor function |
{sap.ui.base.Metadata} | Metadata object describing this class |
Expects following event parameters:
- 'value' of type
string
The new value of thesap.m.DateRangeSelection
. - 'valid' of type
boolean
Indicator for a valid date. - 'from' of type
object
Current start date after change. - 'to' of type
object
Current end date after change.
{Map} | mArguments? | The arguments to pass along with the event. |
{sap.m.DateRangeSelection} | this to allow method chaining |
dateValue
. The start date of the range as JavaScript Date object. This is independent from any formatter.
Note: If this property is used, the value
property should not be changed from the caller.
{object} | the value of property dateValue |
delimiter
. Delimiter between start and end date. Default value is "-". If no delimiter is given, the one defined for the used locale is used.
Default value is -
.
{string} | Value of property delimiter |
secondDateValue
. The end date of the range as JavaScript Date object. This is independent from any formatter.
Note: If this property is used, the value
property should not be changed from the caller.
{object} | Value of property secondDateValue |
value
. Returns a date as a string in the format defined in property displayFormat
.
Note: As the value string always used the displayFormat
, it is both locale-dependent and calendar-type-dependent.
If this property is used, the dateValue
property should not be changed from the caller.
{string} | the value of property value |
valueFormat
. Note: Property valueFormat
is not supported in the sap.m.DateRangeSelection
control.
{string} | the value of property valueFormat |
dateValue
. The start date of the range as JavaScript Date object. This is independent from any formatter.
Note: If this property is used, the value
property should not be changed from the caller.
{object} | oDateValue | New value for property dateValue |
{sap.m.DatePicker} | this to allow method chaining. |
delimiter
. Delimiter between start and end date. Default value is "-". If no delimiter is given, the one defined for the used locale is used.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is -
.
{string} | sDelimiter | New value for property delimiter |
{sap.m.DateRangeSelection} | Reference to this in order to allow method chaining |
secondDateValue
. The end date of the range as JavaScript Date object. This is independent from any formatter.
Note: If this property is used, the value
property should not be changed from the caller.
When called with a value of null
or undefined
, the default value of the property will be restored.
{object} | oSecondDateValue | New value for property secondDateValue |
{sap.m.DateRangeSelection} | Reference to this in order to allow method chaining |
value
. Expects a date as a string in the format defined in property displayFormat
.
Note: As the value string always used the displayFormat
, it is both locale-dependent and calendar-type-dependent.
If this property is used, the dateValue
property should not be changed from the caller.
{string} | sValue | The new value of the input. |
{sap.m.DatePicker} | this to allow method chaining. |
valueFormat
. Note: Property valueFormat
is not supported in the sap.m.DateRangeSelection
control.
{string} | sValueFormat | New value for property valueFormat |
{sap.m.DateRangeSelection} | this to allow method chaining |
from
. Start date of the range.
- Deprecated:
- Since version 1.22.0 Use
dateValue
instead.
{object} | Value of property from |
to
. End date of the range.
- Deprecated:
- Since version 1.22.0 Use
secondDateValue
instead.
{object} | Value of property to |
from
. Start date of the range.
When called with a value of null
or undefined
, the default value of the property will be restored.
{object} | oFrom | New value for property from |
- Deprecated:
- Since version 1.22.0 Use
dateValue
instead.
{sap.m.DateRangeSelection} | Reference to this in order to allow method chaining |
to
. End date of the range.
When called with a value of null
or undefined
, the default value of the property will be restored.
{object} | oTo | New value for property to |
- Deprecated:
- Since version 1.22.0 Use
secondDateValue
instead.
{sap.m.DateRangeSelection} | Reference to this in order to allow method chaining |