on 07-17-2017 6:22 AM
Hi Experts,
I have a requirement where i am using sap.m.Datepicker object and i have to allow selection of current and future dates only. Past Date values should be grayed out. I have tried
minDate property but it's not allowing user to select present date. Only future date selection is possible.
My Code is as follows--
Date.prototype.yyyymmdd = function() {
var mm = this.getMonth() + 1; // getMonth() is zero-based
var dd = this.getDate();
return [
(dd>9 ? '' : '0') + dd,
(mm>9 ? '' : '0') + mm,
this.getFullYear()
].join('.');
};
var dateSelect = new sap.m.DatePicker(
"dp_vesselArrDate",
{
width : "250px",
displayFormat : "dd.MM.yyyy",
valueFormat : "dd.MM.yyyy",
minDate:
yyyymmdd
, change : function( oControlEvent) { this .setValueState(sap.ui.core.ValueState.None); if (this.getValue() === "") { this .setValueState(sap.ui.core.ValueState.Error) } } }),
Hi,
you can use the following:
minDate="{customModel>/currentDate}"
where customModel is:
var model = new JSONModel({
currentDate: new Date()
});
And I initialize the model in the Component.js
And for your particular case you can use:
minDate: new Date()
when you initialize the control.
KR,
Ivan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.