In my process we have a deadline which is a date. But this date is not set until a certain state has been reached. Say i want to display this date before it has been set and it is still initial.
The date is returned as a string and thus 00000000 in my model. (I understand that strings are not dates, but this was choosen and i have to go with it.)
Here is the control:
<DatePicker type="Date" placeholder="{i18n>DateStateUnknown}"
enabled="{
parts : [
{path : 'settings>/incidentLock/MayChangeResponsible'},
{path : 'DeadlineDate'}
], formatter: 'com.company.inc.util.Formatter.mayChangeDeadline' }"
displayFormat="long"
value="{path:'DeadlineDate',
type: 'sap.ui.model.type.String',
constraints: { minLength : 2},
formatter: 'com.company.inc.util.Formatter.setBaseDate'}"
valueFormat="yyyyMMdd" />
My formatter looks like this:
setBaseDate: function(val){
try{
if(val=="00000000"){
return "";
}else{
return val;
}
}catch(e){
return "";
}
},
The diplay works as a expected. Nothing is displayed when the date is empty. The only thing is that with this formatter I loose my connection to the odata model. This means that whenever I make a change to the value, it does not reflect in the odata model and thus I cannot save this date. The same holds true when I set a value for the first time, when the control is still empty.
Does anybody know how to fix this? I'd rather not look at other options as hiding the field.