如何在SAPUI中的表组件上使用嵌套OData对象?

如何在SAPUI中的表组件上使用嵌套OData对象?,odata,sapui5,Odata,Sapui5,我有以下OData对象: <?xml version="1.0" encoding="UTF-8"?> <EntityType Name="Subscription"> <Key> <PropertyRef Name="IdSuscription" /> </Key> <Property Name="Amount" Type="Edm.Decimal" Nullable="false" Precisi

我有以下OData对象:

<?xml version="1.0" encoding="UTF-8"?>
<EntityType Name="Subscription">
   <Key>
      <PropertyRef Name="IdSuscription" />
   </Key>
   <Property Name="Amount" Type="Edm.Decimal" Nullable="false" Precision="10" Scale="2" />
   <Property Name="AutomaticRenewal" Type="Edm.String" Nullable="false" MaxLength="1" />
   <Property Name="Created" Type="Edm.DateTime" Nullable="false" />
   <Property Name="CreatedBy" Type="Edm.Int32" Nullable="false" />
   <Property Name="ExpirationDate" Type="Edm.DateTime" Nullable="true" />
   <Property Name="IdSuscription" Type="Edm.Int32" Nullable="false" />
   <Property Name="LastUpdate" Type="Edm.DateTime" Nullable="true" />
   <Property Name="Plan" Type="Edm.Int32" Nullable="false" />
   <Property Name="StartDate" Type="Edm.DateTime" Nullable="true" />
   <Property Name="Status" Type="Edm.String" Nullable="false" MaxLength="1" />
   <Property Name="UpdatedBy" Type="Edm.Int32" Nullable="true" />
   <Property Name="UserSystem" Type="Edm.Int64" Nullable="true" />
   <NavigationProperty Name="PlanDetails" Relationship="Model.Subscription_Plan_Many_One0" FromRole="Subscription" ToRole="Plan" />
   <NavigationProperty Name="UserSystemDetails" Relationship="Model.Subscription_UserSystem_Many_One0" FromRole="Subscription" ToRole="UserSystem" />
</EntityType>

<?xml version="1.0" encoding="UTF-8"?>
<EntityType Name="Plan">
   <Key>
      <PropertyRef Name="IdPlan" />
   </Key>
   <Property Name="Amount" Type="Edm.Decimal" Nullable="false" Precision="12" Scale="2" />
   <Property Name="Description" Type="Edm.String" Nullable="false" MaxLength="50" />
   <Property Name="ExpirateDate" Type="Edm.DateTime" Nullable="true" />
   <Property Name="FeaturesDescription" Type="Edm.String" Nullable="false" MaxLength="2147483647" />
   <Property Name="FreeAccount" Type="Edm.String" Nullable="true" MaxLength="1" />
   <Property Name="IdPlan" Type="Edm.Int32" Nullable="false" />
   <Property Name="Status" Type="Edm.String" Nullable="false" MaxLength="1" />
</EntityType>

我正在创建一个表,其中显示订阅及其各自的计划。计划说明将显示在“计划”列中。但我不明白,我不明白:

<t:Table
                        rows="{/Subscriptions?$filter=Plan eq 1}"
                        selectionMode="None">
                        <t:toolbar>
                            <Toolbar>
                                <content>
                                    <Title id="title" text="Listado de Suscripciones" />
                                    <ToolbarSpacer/>                        
                                    <Button
                                        icon="sap-icon://add"
                                        tooltip="Agregar Suscripciones"
                                        press="addSuscription"/>

                                    <Switch
                                        state="true"
                                        customTextOn="on"
                                        customTextOff="off"
                                        tooltip="enable select all items"
                                        change="onSwitchChange"/>
                                </content>
                            </Toolbar>
                        </t:toolbar>

                        <t:columns>
                            <t:Column width="10rem">
                                <Label text="Plan" />
                                <t:template>
                                    <Text text="{/PlanDetails/Description}"/>
                                </t:template>
                            </t:Column>

                            <t:Column width="6rem">
                                <Label text="Precio" />
                                <t:template>
                                    <Text text="{Amount}"/>
                                </t:template>
                            </t:Column>

                            <t:Column width="6rem">
                                <Label text="F. Inicio" />
                                <t:template>
                                    <Text text="{StartDate}"/>
                                </t:template>
                            </t:Column>

                            <t:Column width="6rem">
                                <Label text="F. Exp." />
                                <t:template>
                                    <Text text="{ExpirationDate}"/>
                                </t:template>
                            </t:Column>

                            <t:Column width="3rem">
                                <Label text="" />
                                <t:template>
                                    <Button icon="sap-icon://delete" width="38px" press="deleteSuscription"/>
                                </t:template>
                            </t:Column>
                        </t:columns>
                    </t:Table>

我测试了这些方法,但它们都不起作用:

  • {/PlanDetails/Description}
  • {平面细节/说明}
  • {/计划/说明}
  • {计划/说明}
求你了,我需要你的支持


谢谢

如果使用的是sap.m.Table,则需要设置该表的数据绑定 在属性“项”上。在您的情况下,实体是“订阅”。必须将筛选器设置为属性“items”中的参数


如果使用的是sap.m.Table,则需要设置表的数据绑定 在属性“项”上。在您的情况下,实体是“订阅”。必须将筛选器设置为属性“items”中的参数


在您的表上尝试以下行绑定。您必须展开嵌套的OData属性“PlanDetails”,因为它是一个导航属性

rows="{
   path: '/Subscriptions',
   parameters: {
       expand: 'PlanDetails'
   },
   filters: [{path: 'Plan', operator: 'EQ', value1: 1}]
}"
在列中,可以使用相对路径:
{PlanDetails/Description}

在表上尝试以下行绑定。您必须展开嵌套的OData属性“PlanDetails”,因为它是一个导航属性

rows="{
   path: '/Subscriptions',
   parameters: {
       expand: 'PlanDetails'
   },
   filters: [{path: 'Plan', operator: 'EQ', value1: 1}]
}"
在列中,可以使用相对路径:
{PlanDetails/Description}

在您的示例中,您没有使用nestes-Odata对象在您的示例中,您没有使用nestes-Odata对象我想知道在哪里可以找到有关如何使用参数和过滤器的更多文档。谢谢@CesarMiguel聚合绑定的通用API可在中找到。对于OData特定的聚合绑定,请看一下。我想知道在哪里可以找到有关如何使用参数和过滤器的更多文档。谢谢@CesarMiguel聚合绑定的通用API可在中找到。对于OData特定的聚合绑定,请参阅。
            <headerToolbar>
                <Toolbar>
                    <Title text="Products" level="H2"/>
                </Toolbar>
            </headerToolbar>
            <columns>
                <Column
                    width="12em">
                    <Text text="Product" />
                </Column>
                <Column
                    minScreenWidth="Tablet"
                    demandPopin="true">
                    <Text text="Supplier" />
                </Column>
                <Column
                    minScreenWidth="Tablet"
                    demandPopin="true"
                    hAlign="Right">
                    <Text text="Dimensions" />
                </Column>
                <Column
                    minScreenWidth="Tablet"
                    demandPopin="true"
                    hAlign="Center">
                    <Text text="Weight" />
                </Column>
                <Column
                    hAlign="Right">
                    <Text text="Price" />
                </Column>
            </columns>
            <items>
                <ColumnListItem>
                    <cells>
                        <ObjectIdentifier
                            title="{Name}"
                            text="{ProductId}"/>
                        <Text
                            text="{SupplierName}" />
                        <Text
                            text="{Width} x {Depth} x {Height} {DimUnit}" />
                        <ObjectNumber
                            number="{WeightMeasure}"
                            unit="{WeightUnit}"
                            state="{
                                path: 'WeightMeasure',
                                formatter: 'sap.m.sample.Table.Formatter.weightState'
                            }" />
                        <ObjectNumber
                                number="{
                                    parts:[{path:'Price'},{path:'CurrencyCode'}],
                                    type: 'sap.ui.model.type.Currency',
                                    formatOptions: {showMeasure: false}
                                }"
                                unit="{CurrencyCode}" />
                    </cells>
                </ColumnListItem>
            </items>
        </Table>
    </mvc:View>
rows="{
   path: '/Subscriptions',
   parameters: {
       expand: 'PlanDetails'
   },
   filters: [{path: 'Plan', operator: 'EQ', value1: 1}]
}"