SAPUI5: get model-data of current select

…衆ロ難τιáo~ 提交于 2019-12-11 12:16:49

问题


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:

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


回答1:


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

then you can use something like

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

or you can access the member of your object with

var agr = object.Agr;

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

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


来源:https://stackoverflow.com/questions/36197401/sapui5-get-model-data-of-current-select

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!