Reputation: 1
I want to show data from 2 odata entities that have a one to many relationship inside a SAPUI5 table.
I have tried multiple ways of referencing in the table (e.g entries/title). Debugging showed that the data from entries is received but not displayed in the table.
<Table
items="{
path: '/Line',
parameters : {
expand : 'entries'
}
}" >
<columns>
<Column />
<Column />
</columns>
<items>
<ColumnListItem>
<Label text="{ID}" />
<Label text="{title}
{shape}" />
</ColumnListItem>
</items>
</Table>
This is my metadata.xml
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:sap="http://www.sap.com/Protocols/SAPData" xmlns:ux="http://www.sap.com/Protocols/OData4SAP/UX" xmlns:gp="http://www.sap.com/Protocols/SAPData/GenericPlayer" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="2.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="TimelineService">
<EntityType Name="Entry">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.Int32" Nullable="false"/>
<Property Name="title" Type="Edm.String"/>
<Property Name="startDate" Type="Edm.DateTimeOffset"/>
<Property Name="shape" Type="Edm.String"/>
<Property Name="lineID_ID" Type="Edm.Int32"/>
<NavigationProperty Name="lineID" Relationship="TimelineService.Entry_lineID" FromRole="Entry" ToRole="Line"/>
</EntityType>
<EntityType Name="Line">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.Int32" Nullable="false"/>
<NavigationProperty Name="entries" Relationship="TimelineService.Entry_lineID" FromRole="Line" ToRole="Entry"/>
</EntityType>
<Association Name="Entry_lineID">
<End Type="TimelineService.Entry" Multiplicity="*" Role="Entry"/>
<End Type="TimelineService.Line" Multiplicity="0..1" Role="Line"/>
<ReferentialConstraint>
<Principal Role="Line">
<PropertyRef Name="ID"/>
</Principal>
<Dependent Role="Entry">
<PropertyRef Name="lineID_ID"/>
</Dependent>
</ReferentialConstraint>
</Association>
<EntityContainer Name="EntityContainer" m:IsDefaultEntityContainer="true">
<EntitySet Name="Entry" EntityType="TimelineService.Entry"/>
<EntitySet Name="Line" EntityType="TimelineService.Line"/>
<AssociationSet Name="Entry_lineID" Association="TimelineService.Entry_lineID">
<End EntitySet="Entry" Role="Entry"/>
<End EntitySet="Line" Role="Line"/>
</AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Upvotes: 0
Views: 2597
Reputation: 329
Try this solution below:
Open your Controller, and execute a bind element to your context controller.
this.getView().bindElement({
path : "/Line",
parameters : {
"expand" : "entries"
}
});
Now, modify your View
<Table items="{
path: 'entries'
}">
<columns>
<Column />
<Column />
</columns>
<items>
<ColumnListItem>
<Label text="{ID}" />
<Label text="{title}
{shape}" />
</ColumnListItem>
</items>
Thank you.
Upvotes: 1