我正在使用 SAPUI5 和 OData V4 模型,并以 ASP.NET 作为后端。
我的预订有状态。我需要一个用户可以更改预订状态的功能。所有状态都是预定义的并且已经存在于数据库中。我只需要将“预订”更改为“状态”,并且我想为此使用 ODataModel,最好可以从 sap.m.Select 中选择“状态”。
这可能吗?或者我是否必须在 Select 上使用更改事件并手动发出 PUT 请求?
我的(减少的)OData 元数据:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
<Schema Namespace="Namespace"
xmlns="http://docs.oasis-open.org/odata/ns/edm">
<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="http://docs.oasis-open.org/odata/ns/edm">
<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>
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();
});
}
<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>
您的视图上下文中的对象是什么样子的?导航属性是直接作为扩展属性传递还是您必须稍后手动请求它?