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



我有以下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}
  • {plandetails/description}
  • {/plan/description}
  • {plan/Descript}

请,我需要您的支持。

谢谢!

尝试在表上绑定以下行。您必须扩展嵌套的odata属性" plandetails",因为它是导航属性。

rows="{
   path: '/Subscriptions',
   parameters: {
       expand: 'PlanDetails'
   },
   filters: [{path: 'Plan', operator: 'EQ', value1: 1}]
}"

在您的列中,您可以使用相对路径: {PlanDetails/Description}

如果您使用的是 sap.m.table ,则需要设置表的数据绑定在属性上"项目" 。在您的情况下,是实体"订阅"。过滤器必须设置为属性"项目"中的参数。

    <mvc:View
        controllerName="sap.m.sample.Table.Table"
        xmlns:l="sap.ui.layout"
        xmlns:mvc="sap.ui.core.mvc"
        xmlns="sap.m">
        <Table id="idProductsTable"
            inset="false"
          items="{ path: '/ProductCollection',
                   filters: [{path: 'Product', operator: 'StartsWith', value1: 'B'}">
            <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>

最新更新