SAPUI5:获取当前选择的模型数据 [英] SAPUI5: get model-data of current select

查看:500
本文介绍了SAPUI5:获取当前选择的模型数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个详细信息页面(主/详细信息),在该页面中,我将模型的密钥作为参数:

I have a detail page (Master/Detail), where I get the key of a model as a parameter:

onRoutePatternMatched : function(oEvent) {
            var key= oEvent.getParameter("arguments").key;
            var oViewModel = this.getView().getModel("model");
            var _sProductPath = "model>/ZSDATLOG_MACHMODELSet('" + key+ "')";

            this.getView().setBindingContext(oViewModel);
            this.getView().bindElement({
                path: _sProductPath
            });

现在,我已成功在视图中显示明细数据.

Now I successfully display the detail data in the view.

现在,我想在控制器的进一步功能中读取模型的当前行.

Now I want to read the current row of the model in a further function of the controller.

    btnPress : function() {
        var context = this.getView().getBindingContext();
        var object = context.getProperty("/");

通过这段代码,我几乎得到了我的元素:

With this code I nearly get my elements:

现在该对象位于我的变量object中. 我应该如何获取属性Agr?

Now that object is in my variable object. How should I get the attribute Agr?

推荐答案

首先,应使用var context = this.getView().getBindingContext("model");,就像使用命名模型一样.

First you should use var context = this.getView().getBindingContext("model"); as you are using a named model.

然后您可以使用

var agr = context.getProperty("Agr");

或者您可以通过以下方式访问对象的成员

or you can access the member of your object with

var agr = object.Agr;


如果要访问 ZSDATLOG_MACHMODELSet('VBP00099999000117')之类的对象成员,则可以使用以下语法:


If you want to access a object member like ZSDATLOG_MACHMODELSet('VBP00099999000117') you can use this syntax:

var agr = object["ZSDATLOG_MACHMODELSet('VBP00099999000117')"].Agr;

这篇关于SAPUI5:获取当前选择的模型数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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