我有以下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>
我正在创建一个表格,我将在其中显示订阅及其各自的计划。计划说明将显示在&#34;计划&#34;列上。但是我没有表现出来:
<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>
我测试了这些方法,但它们都不起作用:
拜托,我需要你的支持。
谢谢!
答案 0 :(得分:1)
如果您使用 sap.m.Table ,则需要设置表格的数据绑定 在物业&#34; items&#34; 。在您的情况下是实体&#34;订阅&#34;。必须将过滤器设置为属性&#34; items&#34;。
中的参数$(document).ready(function() {
$("div").addClass("hidden");
});
var count = $("#container > div").length;
$(":button").click(function() {
if (count > 0) {
count--;
}
});
<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'}">
答案 1 :(得分:1)
在表格上尝试以下行绑定。您必须扩展嵌套的OData属性“PlanDetails”,因为它是一个导航属性。
rows="{
path: '/Subscriptions',
parameters: {
expand: 'PlanDetails'
},
filters: [{path: 'Plan', operator: 'EQ', value1: 1}]
}"
在您的列中,您可以使用相对路径:
{PlanDetails/Description}