我在 ODATA SAPUI5 应用程序中使用嵌套 JSON 文件作为模型数据,但我无法访问嵌套数据。
JSON 内容
[{
"testcase": {
"specification": "SRS PR 28717 – Deposit in Brazilian Reais",
"execution": {
"description": "DESC",
"bca_cn_acct_01": {
"header": {
"section": "Field / Section Name",
"data": "Data to Enter / Value to Select",
"action": "Activity / Check / Comment"
},
"frame": {
"ID": 1,
"title": "Create Account: Initial Screen",
"data": [{
"key": "Contract Start",
"value": "02/16/2000",
"action": ""
}, {
"key": "Contract Manager",
"value": "GH_RAMOSCL",
"action": ""
}, {
"key": "Product",
"value": "BR_IOFTC3",
"action": ""
}, {
"key": "Account Holder",
"value": "GH_IOF_COR",
"action": "Press Enter"
}]
}
}
},
"result": "Teste"
}}]
在我的视图文件中,我想以列表的形式访问标签内的数据:
<core:View controllerName="sap.ui.demo.MockServer.controller.App" xmlns:core="sap.ui.core" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="sap.m">
<!-- <List headerText="{i18n>headerText}" id="list" items="{/Meetups}" noDataText="{i18n>noDataText}">
<items>
<ObjectListItem number="{ path: 'EventDate', type: 'sap.ui.model.type.DateTime', formatOptions: { style: 'medium' } }" title="{Title}">
<attributes>
<ObjectAttribute text="{Description}"/>
</attributes>
</ObjectListItem>
</items>
</List>
<Button press="onPressAction" text="{i18n>loadFirstItems}"></Button> -->
<List headerText="{i18n>headerText}" id="list" items="{/Meetups}" noDataText="{i18n>noDataText}">
<items>
<ObjectListItem number="{ path: 'EventDate', type: 'sap.ui.model.type.DateTime', formatOptions: { style: 'medium' } }"
title="{testcase/execution/description}">
<attributes>
<ObjectAttribute text="{specification}"/>
</attributes>
</ObjectListItem>
</items>
</List>
<Table id="table" items="{/Meetups}">
<columns>
<Column width="12em">
<Text text="Field / Section Name"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="Data to Enter / Value to Select"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="Activity / Check / Comment"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier title="{testcase/execution/bca_cn_acct_01/frame/data/key}" class="sapMTableContentMargin"/>
<!-- <Text text="{testcase/execution/bca_cn_acct_01/bca_dte_event_begin_d}" /> -->
<Text text="{testcase/execution/bca_cn_acct_01/frame/data/value}"/>
</cells>
</ColumnListItem>
</items>
</Table>
<Button press="onPressAction" text="{i18n>loadFirstItems}"></Button>
但是,字段键和值的数据不会作为列表检索,尽管它们是 JSON 数据标签内的数组。
我使用 SAPUI5 库中的示例教程作为基础:https ://sapui5.hana.ondemand.com/#docs/guide/7a78f1b707c248fd9ec53dcb5f10814c.html
在下面你可以找到我一直在使用的元数据文件:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<edmx:Edmx Version="1.0"
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
<Schema Namespace="NerdMeetup.Models"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<EntityType Name="Meetup">
<ComplexType Name="testcase">
<ComplexType Name="execution">
<!-- Create Payment Item -->
<ComplexType Name="bca_cn_acct_01">
<ComplexType Name="header">
<Property Name="section" Type="Edm.String" Nullable="false" />
<Property Name="data" Type="Edm.String" Nullable="false" />
<Property Name="action" Type="Edm.String" Nullable="false" />
</ComplexType>
<ComplexType Name="frame">
<Property Name="ID" Type="Edm.Int32" Nullable="false" />
<Property Name="title" Type="Edm.String" Nullable="false" />
<ComplexType Name="data">
<Property Name="key" Type="Edm.Int32" Nullable="false" />
<Property Name="value" Type="Edm.Int32" Nullable="false" />
<Property Name="action" Type="Edm.Int32" Nullable="true" />
</ComplexType>
</ComplexType>
<Property Name="bca_dte_event_begin_d" Type="Edm.String" Nullable="false" />
<Property Name="bca_dte_orgunit_cnmgt" Type="Edm.String" Nullable="false" />
<Property Name="fspr_prodext_y" Type="Edm.String" Nullable="false" />
<Property Name="bca_dte_bupa_acchold" Type="Edm.String" Nullable="false" />
</ComplexType>
</ComplexType>
<Property Name="specification" Type="Edm.String" Nullable="true" />
</ComplexType>
</EntityType>
<EntityContainer Name="NerdMeetups" m:IsDefaultEntityContainer="true">
<EntitySet Name="Meetups" EntityType="NerdMeetup.Models.Meetup" />
<FunctionImport Name="FindUpcomingMeetups" EntitySet="Meetups" ReturnType="Collection(NerdMeetup.Models.Meetup)" m:HttpMethod="GET" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
有任何想法吗?
拥抱