on 06-26-2015 10:54 AM
Hi I have an app which has multiple DatePickers across different views which have the same date format like this: "dd.MM.yyyy". I am implementing this as follows:
// create model for date format
var oDateModel = new sap.ui.model.json.JSONModel();
oDateModel.setData({
dateValue: new Date()
});
sap.ui.getCore().setModel(oDateModel, "et_dateFormat");
new sap.ui.commons.DatePicker("emphiredate-datePicker", {
width: "150px",
value: {
path: "et_dateFormat>/dateValue",
type: new sap.ui.model.type.Date({
pattern: "dd.MM.yyyy",
strictParsing: true
})
},
})
Now. I have DatePicker which needs to just show the current date (for which above example works), then I have datepickers which will be set based on the id code of a person which means it should be empty when the form is first opened. If I use the same datemodel the the value is immediatelly set to current date.
Is it possible to use a custom date pattern and at the same time keep the datepicker empty on first open?
Thanks in advance
Not sure what you mean... if you specify a 'null' value, even with a specific date format, the date picker is empty on first use. See this example: Edit fiddle - JSFiddle
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
my json model looks like this:
var oDateModel = new sap.ui.model.json.JSONModel();
oDateModel.setData({
emphiredate: new Date(),
empborn: null,
born: null,
docreldate: null,
docvalidto: null,
drivinglicencefrom: null,
payvalidfrom: new Date(),
payvalidto: new Date("12.31.9999"),
feevalidfrom: null,
feevalidto: null,
membvalidfrom: null,
membvalidto: new Date("12.31.9999")
});
sap.ui.getCore().setModel(oDateModel, "et_dateFormat");
Later i have a button which adds a new form element dynamically which is a datepicker and I set the value for it as follows:
sap.ui.getCore().getModel("et_dateFormat").setProperty(idOfNewElement, new Date()); // first i add try to add the new property
, new Date());
value: {
path: "et_dateFormat>/" + idOfNewElement, // trying to access the newly added property
type: new sap.ui.model.type.Date({
pattern: "dd.MM.yyyy",
strictParsing: true
})
}
Unfortunatelly nothing happens. The datepickers format is correct but it should be displaying the current date which it actually is not.
Initially,
At the time to set today date,
sap.ui.getCore().getModel("et_dateFormat").setDateValue(new Date());
may be you need to refresh this model to fetch new data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.