Reputation: 187
How can I bind a DataSet to sap.m.DatePicker
?
I would like to show a default Date in my DatePicker. The value is coming from a backend oDataService.
I am familiar with binding DataSets to ComboBox items etc, but on Input Fields or a Date Picker this is not working. I also tried to attach a dataReceived event in the onInit function, but this event is never called.
Does anybody have a working example for me?
Upvotes: 2
Views: 2513
Reputation: 2265
You need to be very careful with the Date and DateTime types. The snippet below works with the dateTime variables in Northwind like this one for example
<DatePicker value="{path:'yourPathToTheODataProperty', type: 'sap.ui.model.type.Date', formatOptions: { style: 'full'}}"></DatePicker>
You can change the format options for a predefined one as explained here or set your own LDML pattern, as described here
Upvotes: 0
Reputation: 139
Here my exemple:
In the view.xml
<DatePicker id="startDateEvent" displayFormat="short"/>
In the controller.js :
var startDate = this.byId("startDateEvent");
startDate.setDateValue(<data date from backend>);
Upvotes: 1