How to bind multiple properties with formatter on one control

82 阅读1分钟

Issue description:
A customer want to display amount with currency like ‘1 USD’ in table column, see below screenshot:

1

you can ref to the following example to bind two properties in one control:

var sAmount = "ReportTableData>ExpectedSalesVolumne_Cy";
var sUnit = "ReportTableData>Unit";
var oFieldTemplate = new sap.m.Label().bindProperty("text",
 { parts: [{path: sAmount }, {path: sUnit } ],
   formatter: function(sNum, sUnit){
  var sNumber = sNum ? sap.ca.ui.model.format.AmountFormat.FormatAmountStandard(sNum, null, 0) : 0; 
  return sNumber + " " + sUnit; } });

var oColumnTemplate = new sap.ui.table.Column({
hAlign: "Right", 
label: new sap.m.Label({text: "Expected Sales Volumne (Weighted)"}),
width: "130px",
sortProperty: "ExpectedSalesVolumne_Cy",
template: oFieldTemplate
});

oTable.addColumn(oColumnTemplate);

要获取更多Jerry的原创文章,请关注公众号"汪子熙":