on 2017 Apr 13 8:39 AM
hi
i have an objectheader which looks like this:
<ObjectHeader
id="objectHeader"
intro="{Supplier}"
title="Business area: {BusArea}"
icon="{
path: 'DueDate',
formatter: '.formatter.iconExpired'
}"
number="{PriceIBTW}"
numberUnit="{Valuta}">
so i want the icon to change depending on the DueDate. my formatter looks like this:
iconExpired : function(oValue) {
var dd = oValue.getDate();
var mm = oValue.getMonth() + 1; //January is 0!
var yyyy = oValue.getFullYear();
var idueDate = (yyyy * 10000) + (mm * 100) + dd;
var today = new Date();
dd = today.getDate();
mm = today.getMonth() + 1; //January is 0!
yyyy = today.getFullYear();
var iToday = (yyyy * 10000) + (mm * 100) + dd;
if (idueDate < iToday) {
return "sap-icon://error";
} else {
return "";
}
}
but my oValue in the formatter seems to be null, but when i use the DueDate in my object header, for example in the intro, it displays on the screen nice and smooth. i don't understand what i'm doing wrong, can you guys help me?
formatter function might be called twice, and first time you may get null,
put your code inside a condition, like below and check if its working.
if(oValue != null){
// your code here
}
something like this,
var sIcon = "";
if (oValue != null) {
var dd = oValue.getDate();
var mm = oValue.getMonth() + 1; //January is 0!
var yyyy = oValue.getFullYear();
var idueDate = (yyyy * 10000) + (mm * 100) + dd;
var today = new Date();
dd = today.getDate();
mm = today.getMonth() + 1; //January is 0!
yyyy = today.getFullYear();
var iToday = (yyyy * 10000) + (mm * 100) + dd;
if (idueDate < iToday) {
sIcon = "sap-icon://error";
}
}
return sIcon;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
first time called while rendering and second time while binding the table, as expected for table control i guess, for normal control it should not be.
check console if any errors.
what is the data type of 'DueDate' ? is this datetime ?
actually icon is expecting string, ultimately from formatter it is coming as string only but this may be a check. check if datatype is causing issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is the error i get in the debugger:
before this error nothing unusual.
type of oValue is datetime. here is a screenshot from the debugger in another formatter where i pass the exact same value.
the type is also not the problem. when i pass the supplier(which is a string) oValue is still null.
thanks for the fast reply btw.
User | Count |
---|---|
73 | |
10 | |
9 | |
8 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.