SAPUI5中Odata模型中实体的getProperty不工作

SAPUI5中Odata模型中实体的getProperty不工作,odata,sapui5,Odata,Sapui5,我有一个带有实体的oData模型:Order、OrderInformation。订单和订单信息之间存在1:1的关联 现在在视图中,基于OrderInformation中的值,我应该隐藏/显示一个按钮 在控制器中,按照以下逻辑获取OrderInformation->appUrl的值不起作用,但我可以读取实体“Order”的属性 Init: function(){ // Not working var prop = this.getView().getModel().getPro

我有一个带有实体的oData模型:Order、OrderInformation。订单和订单信息之间存在1:1的关联

现在在视图中,基于OrderInformation中的值,我应该隐藏/显示一个按钮

在控制器中,按照以下逻辑获取OrderInformation->appUrl的值不起作用,但我可以读取实体“Order”的属性

   Init: function(){
   // Not working
    var prop = this.getView().getModel().getProperty("/OrderInformations('"+ this._orderId + "')/appUrl");
   // Working
    var prop = this.getView().getModel().getProperty("/Orders('"+ this._orderId + "')/orderType");
    }
在事务/IWFND/GW_客户端中,以下查询为我提供了正确的值

/sap/opu/odata/sap/<<ServiceURL>>/OrderInformations('132123')/appUrl  
有人能告诉我出了什么问题吗


Nilesh

您可以使用oModel.read函数触发对后端的请求,在成功处理程序中读取响应结果并处理接收到的数据

var test = oModel.read("OrderInformations('" + this._orderId + "')", {
    success: function(oData, response) {
        var appUrl = oData.result.appUrl; //response.data.appUrl also works
        // do something
    },
    error: function (oError) {
        // Error handling on failed response
    }
});
API参考:

我不明白你写的这句话:

在控制器中,按照逻辑获取 OrderInformation->appUrl不起作用,但我可以读取的属性 实体“订单”

   Init: function(){
   // Not working
    var prop = this.getView().getModel().getProperty("/OrderInformations('"+ this._orderId + "')/appUrl");
   // Working
    var prop = this.getView().getModel().getProperty("/Orders('"+ this._orderId + "')/orderType");
    }
Order是另一个具有属性的实体,其地址如上所述? 您是这样初始化您的模型的:
/sap/opu/odata/sap//订单
OrderInformation
是订单的相关实体吗?如果是,则使用odata服务的导航属性扩展读取,该属性定义两个实体之间的关系

我希望这能回答你的问题,如果还剩下什么,请告诉我


致意

您可以使用oModel.read函数触发对后端的请求,在成功处理程序中读取响应结果并处理接收到的数据

var test = oModel.read("OrderInformations('" + this._orderId + "')", {
    success: function(oData, response) {
        var appUrl = oData.result.appUrl; //response.data.appUrl also works
        // do something
    },
    error: function (oError) {
        // Error handling on failed response
    }
});
API参考:

我不明白你写的这句话:

在控制器中,按照逻辑获取 OrderInformation->appUrl不起作用,但我可以读取的属性 实体“订单”

   Init: function(){
   // Not working
    var prop = this.getView().getModel().getProperty("/OrderInformations('"+ this._orderId + "')/appUrl");
   // Working
    var prop = this.getView().getModel().getProperty("/Orders('"+ this._orderId + "')/orderType");
    }
Order是另一个具有属性的实体,其地址如上所述? 您是这样初始化您的模型的:
/sap/opu/odata/sap//订单
OrderInformation
是订单的相关实体吗?如果是,则使用odata服务的导航属性扩展读取,该属性定义两个实体之间的关系

我希望这能回答你的问题,如果还剩下什么,请告诉我


致以最诚挚的问候

您好,您在分析中的表现非常出色。我只是不想用mode.read再打一次电话。问题似乎是我试图读取一些甚至并没有加载到内存中的内容的属性。我确实使用了Mode.read。谢谢嗨,你在分析中是正确的。我只是不想用mode.read再打一次电话。问题似乎是我试图读取一些甚至并没有加载到内存中的内容的属性。我确实使用了Mode.read。谢谢