How can local scope objects pass as parameter into formatter functions. I only know how to pass values from the binding into the formatter function but I need to pass additional objects from local scope into the formatter function.
// request the order operations and bind them to the operation list
oView.getModel().read(sPath + "/OperationSet", {
success: function (oData, oResponse) {
if (oData && oData.results) {
var oOrder = oView.getBindingContext().getObject();
// I need sOrderType inside the external formatter function
var sOrderType = oOrder.OrderType;
operationList.bindAggregation("items", {
path: sPath + "/OperationSet",
template: new sap.m.StandardListItem({
title: "{Description}",
info: "{DurationNormal} {DurationNormalUnit}",
visible: {
parts: [{path: 'Activity'}],
formatter: de.example.util.Formatter.myFormatterFunction
}
}),
filters: []
});
}
},
error: function (oData) {
jQuery.sap.log.error("Could not read order operations");
}
});
You can:
Also bind to other values that contain the same information as the one in oMyObject
Create a closure to capture oMyObject and make it available inside the formatter. e.g.:
Store the information in oMyObject somewhere in the model and access that model inside the formatter function (although a bit of an antipattern)