admin管理员组文章数量:1122832
I'm using SAPUI5 with an OData V4 Model with ASP.NET as a backend.
I have Reservations which have a stauses. I need a functionality that the user can change the Status of a Reservation. All statuses are predefined and already exits on the database. I just need to change the from the Reservation to the Status and I want to use the ODataModel for that, preferably the Status being selectable from a sap.m.Select.
Is this possible? Or do I have to use a change-Event on the Select and make a PUT request by hand?
My (reduced) OData metadata:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx=";>
<edmx:DataServices>
<Schema Namespace="Namespace"
xmlns=";>
<EntityType Name="Reservation">
<Key>
<PropertyRef Name="Id" />
</Key>
<NavigationProperty Name="Status" Type="Namespace.ReservationStatus" />
<NavigationProperty Name="Resources" Type="Collection(Namespace.Resource)" />
</EntityType>
<EntityType Name="ReservationStatus">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Name" Type="Edm.String" Nullable="false" MaxLength="120" />
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
</EntityType>
<EntityType Name="Resource">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Name" Type="Edm.String" MaxLength="120" />
<NavigationProperty Name="Reservations" Type="Collection(Namespace.Reservation)" />
</EntityType>
</Schema>
<Schema Namespace="Default" xmlns=";>
<EntityContainer Name="Container">
<EntitySet Name="Reservations" EntityType="Namespace.Reservation">
<NavigationPropertyBinding Path="Resources" Target="Resources" />
<NavigationPropertyBinding Path="Status" Target="ReservationStatuses" />
</EntitySet>
<EntitySet Name="ReservationStatuses" EntityType="Namespace.ReservationStatus" />
<EntitySet Name="Resources" EntityType="Namespace.Resource">
<NavigationPropertyBinding Path="Reservations" Target="Reservations" />
</EntitySet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Frontend implementations
Create Reservation through ODataModel and open Dialog
onCreateReservationButtonPress() {
const oAppointment = this.byId("idSinglePlanningCalendar").getBinding("appointments").create();
oAppointment.created().then(() => {
// Dialog is created and stored in this.dialog_reservation
this.getView().addDependent(this.dialog_reservation);
this.dialog_reservation.bindElement({
path: oAppointment.getPath(),
parameters: {
'$expand': 'Status'
}
});
this.dialog_reservation.open();
});
}
Dialog implementation
<c:FragmentDefinition
xmlns="sap.m"
xmlns:c="sap.ui.core"
xmlns:f="sap.ui.layout.form"
>
<f:SimpleForm editable="true">
<Label text="Name" />
<Input
id="idNameInput"
value="{Name}"
maxLength="120"
/>
<Label text="Status" />
<Select items="{/ReservationStatuses}">
<items>
<c:Item
text="{Name}"
key="{Id}"
/>
</items>
</Select>
</f:SimpleForm>
</c:FragmentDefinition>
本文标签: Update NavigationProperty in SAPUI5 with OData V4 Model (with ASPNET backend)Stack Overflow
版权声明:本文标题:Update NavigationProperty in SAPUI5 with OData V4 Model (with ASP.NET backend) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736311376a1934715.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论