1. 程式人生 > 其它 >SAPUI5 Walkthrough Step 21: Data Types

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屬性)

<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>

執行