Class sap.m.DatePickerModule: sap/m/DatePicker
This is a date input control with a calendar as date picker.
A date 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 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 DatePicker. You can put a date as a string to the property value or you can put a JavaScript Date object to the property dateValue. Only one of the properties should be used at one time, but they are synchronized internally. What property you should use depends on the use case of the application:
- Use the
valueproperty if you want to bind theDatePickerto a model using thesap.ui.model.type.Date. - Use the
valueproperty if the date is provided as a string from the backend or inside the application (e.g. as ABAP type DATS field). - Use the
dateValueproperty if the date is already provided as a JavaScript Date object or you want to work with a JavaScript Date object.
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 valueFormat is "yyyy-MM-dd", displayFormat is "MMM d, y" and the used locale is English, a valid value string is "2015-07-30", which leads to an output of "Jul 30, 2015".
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 DatePicker is opened. This means that it is not needed for the initial rendering. If the sap.ui.unified library is not loaded before the DatePicker is opened, it will be loaded upon opening. This could lead to a waiting time before a DatePicker is opened the first time. To prevent this, applications using the DatePicker should also load the sap.ui.unified library.
Since: 1.22.0.
sClassName and enriches it with the information contained in oClassInfo.sap.ui.core.Element in the aggregation specialDates.secondaryCalendarType. 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
- displayFormat : string
- valueFormat : string
- dateValue : object
- displayFormatType : string (default: )
- secondaryCalendarType : sap.ui.core.CalendarType
- minDate : object
- maxDate : object
- Aggregations
- specialDates : sap.ui.core.Element[]
In addition, all settings applicable to the base type sap.m.InputBase 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.DatePicker as specified by valueFormat. |
| {boolean} | oControlEvent.getParameters.valid | Indicator for a valid date. |
sClassName and enriches it with the information contained in oClassInfo. oClassInfo might contain the same kind of information as described in sap.m.InputBase.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 |
specialDate to the aggregation specialDates. | {sap.ui.unified.DateTypeRange} | oSpecialDate | the specialDate to add; if empty, nothing is added |
- Since:
- 1.38.5
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
specialDates. - Since:
- 1.38.5
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
Expects following event parameters:
- 'value' of type
stringThe new value of thesap.m.DatePicker. - 'valid' of type
booleanIndicator for a valid date.
| {Map} | mArguments? | the arguments to pass along with the event. |
| {sap.m.DatePicker} | this to allow method chaining |
dateValue. The date 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 dateValue |
displayFormat. The date is displayed in the input field using this format. By default, the medium format of the used locale is used.
Supported format options are pattern-based on Unicode LDML Date Format notation. http://unicode.org/reports/tr35/#Date_Field_Symbol_TableNote: If you use data binding on the value property with type sap.ui.model.type.Date this property will be ignored. The format defined in the binding will be used.
| {string} | Value of property displayFormat |
displayFormatType. Displays date in this given type in input field. Default value is taken from locale settings. Accepted are values of sap.ui.core.CalendarType or an empty string. If no type is set, the default type of the configuration is used. Note: If data binding on value property with type sap.ui.model.type.Date is used, this property will be ignored.
Default value is .
- Since:
- 1.28.6
| {string} | Value of property displayFormatType |
legend, or null. - Since:
- 1.38.5
| {sap.ui.core.Control} |
maxDate. Maximum date that can be shown and selected in the DatePicker. This must be a JavaScript date object.
Note: If the maxDate is set to be before the minDate, the maxDate and the minDate are switched before rendering.
- Since:
- 1.38.0
| {object} | Value of property maxDate |
minDate. Minimum date that can be shown and selected in the DatePicker. This must be a JavaScript date object.
Note: If the minDate is set to be after the maxDate, the maxDate and the minDate are switched before rendering.
- Since:
- 1.38.0
| {object} | Value of property minDate |
secondaryCalendarType. If set, the days in the calendar popup are also displayed in this calendar type If not set, the dates are only displayed in the primary calendar type
- Since:
- 1.34.1
| {sap.ui.core.CalendarType} | Value of property secondaryCalendarType |
specialDates. Date Range with type to visualize special days in the Calendar. If one day is assigned to more than one Type, only the first one will be used.
- Since:
- 1.38.5
| {sap.ui.core.Element[]} |
valueFormat. The date string expected and returned in the value property uses this format. By default the short format of the used locale is used.
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 date string represents an ABAP DATS type, the format should be "yyyyMMdd".
Note: If data binding on value property with type sap.ui.model.type.Date is used, this property will be ignored. The format defined in the binding will be used.
| {string} | Value of property valueFormat |
sap.ui.core.Element in the aggregation specialDates. and returns its index if found or -1 otherwise. | {sap.ui.core.Element} | oSpecialDate | The specialDate whose index is looked for |
- Since:
- 1.38.5
| {int} | The index of the provided control in the aggregation if found, or -1 otherwise |
specialDate to the aggregation specialDates. | {sap.ui.unified.DateTypeRange} | oSpecialDate | the specialDate to insert; if empty, nothing is inserted |
| {int} | iIndex | the 0-based index the specialDate should be inserted at; for a negative value of iIndex, the specialDate is inserted at position 0; for a value greater than the current size of the aggregation, the specialDate is inserted at the last position |
- Since:
- 1.38.5
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
specialDates. Additionally, it unregisters them from the hosting UIArea.
- Since:
- 1.38.5
| {sap.ui.core.Element[]} | An array of the removed elements (might be empty) |
specialDate from the aggregation specialDates. | {sap.ui.unified.DateTypeRange} | oSpecialDate | The specialDate to remove or its index or id |
- Since:
- 1.38.5
| {sap.ui.unified.DateTypeRange} | The removed specialDate or null |
dateValue. The date 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} | oDateValue | New value for property dateValue |
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
displayFormat. The date is displayed in the input field using this format. By default, the medium format of the used locale is used.
Supported format options are pattern-based on Unicode LDML Date Format notation. http://unicode.org/reports/tr35/#Date_Field_Symbol_TableNote: If you use data binding on the value property with type sap.ui.model.type.Date this property will be ignored. The format defined in the binding will be used.
When called with a value of null or undefined, the default value of the property will be restored.
| {string} | sDisplayFormat | New value for property displayFormat |
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
displayFormatType. Displays date in this given type in input field. Default value is taken from locale settings. Accepted are values of sap.ui.core.CalendarType or an empty string. If no type is set, the default type of the configuration is used. Note: If data binding on value property with type sap.ui.model.type.Date is used, this property will be ignored.
When called with a value of null or undefined, the default value of the property will be restored.
Default value is .
| {string} | sDisplayFormatType | New value for property displayFormatType |
- Since:
- 1.28.6
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
| {sap.ui.core.ID|sap.ui.unified.CalendarLegend} | oLegend | ID of an element which becomes the new target of this legend association; alternatively, an element instance may be given |
- Since:
- 1.38.5
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
maxDate. Maximum date that can be shown and selected in the DatePicker. This must be a JavaScript date object.
Note: If the maxDate is set to be before the minDate, the maxDate and the minDate are switched before rendering.
When called with a value of null or undefined, the default value of the property will be restored.
| {object} | oMaxDate | New value for property maxDate |
- Since:
- 1.38.0
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
minDate. Minimum date that can be shown and selected in the DatePicker. This must be a JavaScript date object.
Note: If the minDate is set to be after the maxDate, the maxDate and the minDate are switched before rendering.
When called with a value of null or undefined, the default value of the property will be restored.
| {object} | oMinDate | New value for property minDate |
- Since:
- 1.38.0
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
secondaryCalendarType. If set, the days in the calendar popup are also displayed in this calendar type If not set, the dates are only displayed in the primary calendar type
When called with a value of null or undefined, the default value of the property will be restored.
| {sap.ui.core.CalendarType} | sSecondaryCalendarType | New value for property secondaryCalendarType |
- Since:
- 1.34.1
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
valueFormat. The date string expected and returned in the value property uses this format. By default the short format of the used locale is used.
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 date string represents an ABAP DATS type, the format should be "yyyyMMdd".
Note: If data binding on value property with type sap.ui.model.type.Date is used, this property will be ignored. The format defined in the binding will be used.
When called with a value of null or undefined, the default value of the property will be restored.
| {string} | sValueFormat | New value for property valueFormat |
| {sap.m.DatePicker} | Reference to this in order to allow method chaining |
| {string} | sWidth | new value for width |
| {sap.m.DatePicker} | this to allow method chaining |