加载实体而不将其绑定到视图 [英] Load entity without binding it to a view
问题描述
在控制器(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屋!