๐ invoice๋ฅผ ์์ฑํด๋ณด์.
App.view.xml
<mvc:XMLView viewName="sap.ui.demo.walkthrough.view.Invoicelist" />
InvoiceList.view.xml
viewํด๋์์ ์๋ก์ด ํ์ผ InvoiceList.view.xml
์ ์์ฑํ๋ค.
<mvc:View
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc">
<List
headerText="{i18n>invoiceListTile}"
class="sapUiResponsiveMargin"
width="auto"
items="{invoice>/Invoices}" >
<items>
<ObjectListItem
title="{invoice>Quantity} x {invoice>ProductName}" />
</items>
</List>
</mvc:View>
List
๋ชจ๋์ ๋ฐฐ์ด์ ์ฌ์ฉํ๋ ๋ชจ๋์ด๊ธฐ ๋๋ฌธ์ invoice๋ผ๋ ๋ชจ๋ธ์์ Invoices ํ๋กํฌํฐ๋ก ๋ฐฐ์ด๋ก ๋ ๋ฐ์ดํฐ Invoices๋ฅผ ๋ฐ์ธ๋ฉ ํด์ค๋ค.
๊ทธ๋ผ ํ์ฌ List์ items
์๋ ๋ฐฐ์ด Invoices๊ฐ ๋ฐ์ธ๋ฉ ๋์ด์๋๋ฐ, ๋ฐ์ธ๋ฉ๋ ๋ฐฐ์ด์์ ๊ฐ์ฒด๋ค์ด ์๋ค. aggregation์์ ์๋ ๋ชจ๋์ด ๋ฐ๋ณต๋๋ฉด์ ๊ฐ์ฒด๋ฅผ ์์๋๋ก ํ๋์ฉ ๊ฐ์ ธ์ค๊ฒ ๋๋ค.
๋ฐฐ์ด์ฌ์ฉํ๋ ๋ชจ๋์๋ List, Table, Select, ComboBox๊ฐ ์๋ค. ์ด ๋ชจ๋๋ค์ ๋ฐฐ์ด๋ก ๋ ๋ฐ์ดํฐ๋ฅผ ๋ฐ์ธ๋ฉ ํด์ค์ผ ํ๊ณ aggregation ๋ถ๋ถ์ length๋งํผ ๋ฐ๋ณต์ํจ๋ค. for๋ฌธ์ผ๋ก ์ธ์ํ๋ฉด ์ดํด๊ฐ ์ฝ๋ค.
{invoice>Quantity}
๋ฐฐ์ด์์ ๋ค์ด์๋ ๊ฐ์ฒด์ ํ๋กํฌํฐ ๊ฐ์ ๊ฐ์ ธ์จ๋ค.
๋ฐ๋ณต๋๋ ๋ชจ๋์์์๋
/
๋ฅผ ์๋ตํ๋ค.
i18n_ko.properties
์ธ๋ณด์ด์ค์ ํ์ดํ์ ์ ๋ ฅํ๋ค.
invoiceListTile=Invoices
๐ ๋ฐ์ดํฐ๋ฅผ ๋ฃ์ด๋ณด์.
์์ดํ
์ title์ "{invoice>Quantity} x {invoice>ProductName}"
๋ก ํด๋จ๊ธฐ ๋๋ฌธ์ Quantity x ProductName์ผ๋ก ๋์ค๋๊ฒ์ ํ์ธํ ์ ์๋ค.
invoices.json
์๋ก jsonํ์ผ์ ๋ง๋ค๊ณ ํ์ผ์ ์๋ก ์์ฑํ๋ค.
{
"Invoices": [
{
"ProductName": "Pineapple",
"Quantity": 21,
"ExtendedPrice": 87.2000,
"ShipperName": "Fun Inc.",
"ShippedDate": "2015-04-01T00:00:00",
"Status": "A"
},
{
"ProductName": "Milk",
"Quantity": 4,
"ExtendedPrice": 9.99999,
"ShipperName": "ACME",
"ShippedDate": "2015-02-18T00:00:00",
"Status": "B"
},
{
"ProductName": "Canned Beans",
"Quantity": 3,
"ExtendedPrice": 6.85000,
"ShipperName": "ACME",
"ShippedDate": "2015-03-02T00:00:00",
"Status": "B"
},
{
"ProductName": "Salad",
"Quantity": 2,
"ExtendedPrice": 8.8000,
"ShipperName": "ACME",
"ShippedDate": "2015-04-12T00:00:00",
"Status": "C"
},
{
"ProductName": "Bread",
"Quantity": 1,
"ExtendedPrice": 2.71212,
"ShipperName": "Fun Inc.",
"ShippedDate": "2015-01-27T00:00:00",
"Status": "A"
}
]
}
component.js
์๋ก ์์ฑํ jsonํ์ผ์ ์ฝ์ด์ค์. initํจ์ ์์ ๋ก์ง์ ์ถ๊ฐํ๋ค.
var that = this;
$.ajax({
url:"./json/Invoices.json",
type: "get",
success: function (oResult) {
var oInvoiceModel = new JSONModel(oResult);
that.setModel(oInvoiceModel, "invoice");
}
});
this
๋ ๊ธฐ์กด๋ก์ง์ UIComponent๋ฅผ ๊ฐ๋ฆฌํค๊ฒ ํ๊ธฐ ์ํด success ํจ์ ๋ฐ์๋ค๊ฐ ์ ์ธํด์ค๋ค. this๋ฅผ ์ด๋์ ์ฌ์ฉํ๋์ ๋ฐ๋ผ this๊ฐ ๊ฐ๋ฆฌํค๋๊ฒ ๋ฌ๋ผ์ง๋๋ฐ successํจ์์์ thisํ๋ฉด ๋ค๋ฅธ์ ๋ฅผ ๊ฐ๋ฆฌํค๊ฒ ๋๋ค.
ํ์ผ์ ๊ฐ์ ธ์ค๋๋ฐ ์ฑ๊ณตํ์์ oResult์ ๋ด๊ณ ๋ฐ์ดํฐ๋ฅผ ๋ชจ๋ธ์ ๋ด์ ๋ชจ๋ธ์ invoice ๋ทฐ์ ๋ฐ์ธ๋ฉํ๋ค.
'Fiori > UI5' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[UI5] ์์ (๊ตฌ๊ตฌ๋จ) (0) | 2023.03.08 |
---|---|
[UI5] Data types (0) | 2023.03.08 |
[UI5] Dialogs and Fragments (0) | 2023.03.07 |
[UI5] Pages, Panels, Shell, Margins, Nested View, Custom CSS (0) | 2023.03.07 |
[UI5] ํ๋ฉด ๊ฐ์ (0) | 2023.03.07 |
๋๊ธ