SAPUI5 Walkthrough Step 21: Data Types

https://sapui5.hana.ondemand.com/#/topic/dfe04650afc046e0802abb1a1a90d2d9

 

修改webapp/controller/InvoiceList.controller.js 文件(设置modles:view)

sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "sap/ui/model/json/JSONModel"
], function(Controller, JSONModel) {
    "use strict";

    return Controller.extend("sap.ui.demo.walkthrough.controller.InvoiceList", {
        onInit: function() {
            var oViewModel = new JSONModel({
                currency: "EUR"
            });
            this.getView().setModel(oViewModel, "view");
        }
    });
});

 

修改 webapp/view/InvoiceList.view.xml 文件, (增加controller文件的路径,增加number属性、numberUnit属性)

ObjectListitem

<mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" controllerName="sap.ui.demo.walkthrough.controller.InvoiceList">
    <List headerText="{i18n>invoiceListTitle}" class="sapUiResponsiveMargin" width="auto" items="{invoice>/Invoices}">
        <items>
            <ObjectListItem title="{invoice>Quantity} x {invoice>ProductName}"
                number="{parts: [
                                    {path: 'invoice>ExtendedPrice'}, 
                                    {path: 'view>/currency'}
                                ], 
                            type: 'sap.ui.model.type.Currency', 
                            formatOptions: { showMeasure: false } 
                        }"
                numberUnit="{view>/currency}"/>
        </items>
    </List>
</mvc:View>

 

 

 

 

执行

 

posted @ 2021-07-29 17:43  客于溟  阅读(77)  评论(0)    收藏  举报