๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Fiori/UI5

[UI5] Data types

by clode 2023. 3. 8.
728x90
๋ฐ˜์‘ํ˜•

๐Ÿ˜ ๊ธˆ์•ก๊ณผ ๋‹จ์œ„๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณด์ž.

Invoice๋Š” ์ด๋ฏธ ๋ฉ‹์ง€๊ฒŒ ๊พธ๋ฉฐ์กŒ์ง€๋งŒ, ๊ฐ€๊ฒฉ์ด ๋‚˜์™€์žˆ์ง€ ์•Š๋‹ค๋ฉด ๊ทธ๋ƒฅ ๋ชฉ๋ก์ผ ๋ฟ์ด๋‹ค!

InvoiceList.view.xml

controllerName="sap.ui.demo.walkthrough.controller.InvoiceList"

List์˜ ๋ฐ”๊นฅ์— ๋ฐ‘์—์„œ ์ƒˆ๋กœ ์ƒ์„ฑํ•  InvoiceList ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ์—ฐ๊ฒฐํ•ด์ค€๋‹ค.

    <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}" />

๋ณดํ†ต์€ ํ•˜๋‚˜์˜ ํ”„๋กœํฌํ‹ฐ์— ํ•˜๋‚˜์˜ ๊ฐ’๋งŒ์„ ๋ถˆ๋Ÿฌ์™”๋Š”๋ฐ, ํ•˜๋‚˜์˜ ํ”„๋กœํฌํ‹ฐ์— ์—ฌ๋Ÿฌ ๊ฐ’, ๋ฐฐ์—ด์„ ๋ถˆ๋Ÿฌ์˜ฌ๋• ๊ฐ์ฒด๋กœ ๋„˜๊ธฐ๊ณ  parts ํ”„๋กœํฌํ‹ฐ๋ฅผ ์‚ฌ์šฉํ•ด path๋กœ ์—ฌ๋Ÿฌ ํ”„๋กœํฌํ‹ฐ ๊ฐ’์„ ๋ถˆ๋Ÿฌ์˜จ๋‹ค.

view>/currency๊ฐ€ EUR์ด๋ฏ€๋กœ EUR์˜ ์ˆซ์žํƒ€์ž…์ธ ์†Œ์ˆซ์  ๋‘๋ฒˆ์งธ์ž๋ฆฌ๊นŒ์ง€ ํ‘œ์‹œํ•ด์ค€๋‹ค.

formatOptions๋กœ ์˜ต์…˜์„ ์ค„์ˆ˜ ์žˆ๊ณ , showMeasure๋ฅผ false๋กœ ํ•˜๋ฉด currency ๊ธˆ์•ก ์•ž์— ๋‹จ์œ„๊ฐ€ ์•ˆ๋ณด์ด๊ฒŒ ํ•œ๋‹ค.

true์ผ ๊ฒฝ์šฐ์—๋Š” ์ด๋ ‡๊ฒŒ ์™ผ์ชฝ์— ๋‹จ์œ„๊ฐ€ ํ‘œ์‹œ๋œ๋‹ค.

invoiceList.comtroller.js

controllerํด๋”์— ์ƒˆ๋กœ invoiceList.comtroller.js ํŒŒ์ผ์„ ์ƒˆ๋กœ ์ƒ์„ฑํ•œ๋‹ค.

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");
        }
    });
});

EUR์ธ๊ฒฝ์šฐ ์†Œ์ˆซ์  ๋‘๋ฒˆ์งธ์ž๋ฆฌ๊นŒ์ง€ ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ณด์—ฌ์ค€๋‹ค.



๐Ÿ˜ ํ•ญ๋ชฉ๋ณ„๋กœ ๋‹จ์œ„๋ฅผ ๋‹ค๋ฅด๊ฒŒ ํ•ด๋ณด์ž

Invoice.json

๊ฐ ํ•ญ๋ชฉ์— ํ†ตํ™” ํ”„๋กœํฌํ‹ฐ์™€ ๊ฐ’์„ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค.

 "Currency" : "USD"

InvoiceList.view.xml

๊ธฐ์กด์— ์žˆ๋˜ view>/currency๋ฅผ Invoice>Currency๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค.

๋‘˜๋‹ค currency ํƒ€์ž…์„ ๊ฐ€์ง€๊ณ  ์˜ค๊ฒ ๋‹ค๋Š” ๊ณตํ†ต์ ์ด ์žˆ์ง€๋งŒ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์˜ค๋Š” ๊ณณ์ด ๋‹ค๋ฅด๋‹ค. ์ „์ž๋Š” InvoiceList.controller.js์—์„œ ์ •์˜ํ•œ view๋ผ๋Š” ๋ชจ๋ธ์—์„œ EUR์„ ๊ฐ€์ ธ์™€ ๊ฐ’์„ ๊ณ ์ •์‹œํ‚ค๊ณ  ํ›„์ž๋Š” Invoice.json์„ ๋ฐ˜๋ณตํ•˜๋ฉด์„œ ๊ฐ’์„ ๊ฐ€์ ธ์™€ ํ•ญ๋ชฉ๋ณ„๋กœ ๊ฐ’์„ ๋‹ค๋ฅด๊ฒŒ ์…‹ํŒ…ํ•œ๋‹ค. ๋ฐ˜๋ณต๋˜๋Š” ๋ฐ˜๋ณต๋ฌธ์ด๊ธฐ ๋•Œ๋ฌธ์— /๋ฅผ ์ƒ๋žตํ•œ๋‹ค.

Currency์˜ ํƒ€์ž…์— ๋”ฐ๋ผ์„œ ์ˆซ์žํƒ€์ž…๋„ ๋‹ค๋ฅด๊ฒŒ ํ‘œ์‹œ๋œ๋‹ค. KRW๊ฒฝ์šฐ์—๋Š” ์†Œ์ˆซ์ ์ด ํ•„์š”์—†๊ธฐ ๋•Œ๋ฌธ์— ์†Œ์ˆซ์  ์—†์ด ์ •์ˆ˜์ž๋ฆฌ๋งŒ ๋ณด์—ฌ์ค€๋‹ค.

728x90
๋ฐ˜์‘ํ˜•

'Fiori > UI5' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[UI5] Formatters  (0) 2023.03.08
[UI5] ์˜ˆ์ œ (๊ตฌ๊ตฌ๋‹จ)  (0) 2023.03.08
[UI5] Aggregation Binding  (0) 2023.03.07
[UI5] Dialogs and Fragments  (0) 2023.03.07
[UI5] Pages, Panels, Shell, Margins, Nested View, Custom CSS  (0) 2023.03.07

๋Œ“๊ธ€