加载实体而不将其绑定到视图 [英] Load entity without binding it to a view

查看:72
本文介绍了加载实体而不将其绑定到视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在控制器(Detail.controller.js)中,我要访问尚未绑定到控件的OData-Entity.

In a controller (Detail.controller.js) I want to access an OData-Entity that has not yet been bound to a control.

如果BananaSet的条目0001绑定到视图,则可以通过以下方式访问原始数据

If the entry 0001 of my BananaSet is bound to the view, I can access the raw data via

this.getView().getModel().getProperty("/BananaSet('0001')");

,但是以下内容将返回undefined(除非最近显示).

but the following will return undefined (unless it was displayed recently).

this.getView().getModel().getProperty("/BananaSet('0002')");
this.getView().getModel().getProperty("/MetaDataSet('0001')");

是否有一种方法可以访问尚未绑定的OData模型的数据或实体?

Is there a way to access data or entities of an OData model, that have not yet been bound?

推荐答案

要显式触发对实体的请求,可以使用oData模型的read函数.

To explicitly trigger a request to an entity you may use the read function of the oData model.

这是官方文档:
https://openui5 .hana.ondemand.com/docs/api/symbols/sap.ui.model.odata.v2.ODataModel.html#read

Here is the official documentation:
https://openui5.hana.ondemand.com/docs/api/symbols/sap.ui.model.odata.v2.ODataModel.html#read

this.getView().getModel().read("/BananaSet('001')", {
    success: function (oData) {
        // do something with the Banana data
    }
})

这篇关于加载实体而不将其绑定到视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆