Skip to Content
0
Former Member
Jun 26, 2015 at 09:54 AM

Different DatePickers with same date format pattern

58 Views

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