Gridview SAPUI5自定义控件getAggregation()为空

Gridview SAPUI5自定义控件getAggregation()为空,gridview,sapui5,Gridview,Sapui5,我已经用sapui5编写了一个自定义控件。它是一个虚拟键盘(屏幕键盘),有一个矩阵布局和许多按钮作为聚合。我在控件中添加了一个“public”功能,可以禁用一些按钮。但是当我试图在这个函数中访问它时,除了MatrixLayout聚合之外,我的所有聚合都是空的 有人能帮助我如何访问聚合(按钮)吗? 我尝试过隐藏和公开的可见性。我确实看到生成的访问器,但它们也返回“null”。 如果我尝试获取聚合“\u布局”,则返回MatrixLayout 我正试图通过以下方式访问它: onVirtualK

我已经用sapui5编写了一个自定义控件。它是一个虚拟键盘(屏幕键盘),有一个矩阵布局和许多按钮作为聚合。我在控件中添加了一个“public”功能,可以禁用一些按钮。但是当我试图在这个函数中访问它时,除了MatrixLayout聚合之外,我的所有聚合都是空的

有人能帮助我如何访问聚合(按钮)吗? 我尝试过隐藏和公开的可见性。我确实看到生成的访问器,但它们也返回“null”。 如果我尝试获取聚合“\u布局”,则返回MatrixLayout

我正试图通过以下方式访问它:

    onVirtualKeyboardClickBase : function(oEvent, oController){

    var virtualKeyboard = oEvent.getSource().disableButton("_btnMinus");
    }
这是自定义控件的代码:

   (function () {
    "use strict";

    jQuery.sap.declare("de.vw.timerec.controls.VirtualKeyboard");

    $.sap.includeStyleSheet("css/VirtualKeyboard.css");

    jQuery.sap.require("sap.ui.commons.Button");

    sap.ui.core.Control.extend("de.vw.timerec.controls.VirtualKeyboard", {

        // the control API:
        metadata : {
            properties : {
                /* Business Object properties */
                "title"           : {type : "string"},
                "width"           : {type: "sap.ui.core.CSSSize", defaultValue: "253px" },
                "buttonWidth"     : {type: "sap.ui.core.CSSSize", defaultValue: "57px" },
                "buttonHeight"    : {type: "sap.ui.core.CSSSize", defaultValue: "57px" }
            },

            aggregations : {
                "_layout"    : {type : "sap.ui.commons.layout.MatrixLayout", multiple : false, visibility: "hidden"},
                "_btn1"      : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btn2"      : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btn3"      : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btnDel"    : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btn4"      : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btn5"      : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btn6"      : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btnAlpha"  : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btn7"      : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btn8"      : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btn9"      : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btnBack"   : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btn0"      : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btnComma"  : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"},
                "_btnMinus"  : {type : "sap.ui.commons.Button", multiple : false, visibility: "public"},
                "_btnNext"   : {type : "sap.ui.commons.Button", multiple : false, visibility: "hidden"}
            },

            associations: { },

            events : { 
                click : {enablePreventDefault : true}
            }
        },


        init : function() {

            var oControl = this;
            var oMatrixLayout;
            var oBtn1, oBtn2, oBtn3, oBtnDel, oBtn4, oBtn5, oBtn6, oBtnAlpha, 
            oBtn7, oBtn8, oBtn9, oBtnBack, oBtn0, oBtnComma, oBtnMinus, oBtnNext;

            oMatrixLayout = new sap.ui.commons.layout.MatrixLayout({
                id : this.getId() + "-matrixLayout",
                layoutFixed : true, 
                columns : 4,
                width : "100%"
            });
            this.setAggregation("_layout", oMatrixLayout);

            oBtn1 = this._createButton("1", "1", oControl, true);
            this.setAggregation("_btn1", oBtn1);

            oBtn2 = this._createButton("2", "2", oControl, true);
            this.setAggregation("_btn2", oBtn2);

            oBtn3 = this._createButton("3", "3", oControl, true);
            this.setAggregation("_btn3", oBtn3);

            oBtnDel = this._createButton("", "delete", oControl, false);
            oBtnDel.setIcon("sap-icon://undo");
            this.setAggregation("_btnDel", oBtnDel);
            oMatrixLayout.createRow(oBtn1, oBtn2, oBtn3, oBtnDel);

            oBtn4 = this._createButton("4", "4", oControl, true);
            this.setAggregation("_btn4", oBtn4);

            oBtn5 = this._createButton("5", "5", oControl, true);
            this.setAggregation("_btn5", oBtn5);

            oBtn6 = this._createButton("6", "6", oControl, true);
            this.setAggregation("_btn6", oBtn6);

            oBtnAlpha = this._createButton("Alpha", "alpha", oControl, false);
            this.setAggregation("_btnAlpha", oBtnAlpha);
            oMatrixLayout.createRow(oBtn4, oBtn5, oBtn6, oBtnAlpha);

            oBtn7 = this._createButton("7", "7", oControl, true);
            this.setAggregation("_btn7", oBtn7);

            oBtn8 = this._createButton("8", "8", oControl, true);
            this.setAggregation("_btn8", oBtn8);

            oBtn9 = this._createButton("9", "9", oControl, true);
            this.setAggregation("_btn9", oBtn9);

            oBtnBack = this._createButton("", "back", oControl, false);
            oBtnBack.setIcon("sap-icon://arrow-top");
            this.setAggregation("_btnBack", oBtnBack);
            oMatrixLayout.createRow(oBtn7, oBtn8, oBtn9, oBtnBack);

            oBtn0 = this._createButton("0", "0", oControl, true);
            this.setAggregation("_btn0", oBtn0);

            oBtnComma = this._createButton(",", ",", oControl, true);
            this.setAggregation("_btnComma", oBtnComma);

            oBtnMinus = this._createButton("-", "-", oControl, true);
            this.setAggregation("_btnMinus", oBtnMinus);

            oBtnNext = this._createButton("", "next", oControl, false);
            oBtnNext.setIcon("sap-icon://arrow-bottom");
            this.setAggregation("_btnNext", oBtnNext);
            oMatrixLayout.createRow(oBtn0, oBtnComma, oBtnMinus, oBtnNext);
        },

        onAfterRendering: function () {

        },

        _createButton : function (text, buttonValue, oControl, isDigitButton) { 

            var styleClassName = "virtualKeyboardButtonDigit";
            if (!isDigitButton) styleClassName = "virtualKeyboardButtonSpecial";

            var buttonIdHelper = buttonValue;
            if (buttonValue == ",") {
                buttonIdHelper = "comma";
            }

            if (buttonValue == "-") {
                buttonIdHelper = "minus";
            }

            var buttonId = this.getId() + "virtualKeyboardButton_" + buttonIdHelper;
            var oBtn   = new sap.ui.commons.Button({
                id: buttonId,
                text: text,
                width: this.getProperty("buttonWidth"),
                height: this.getProperty("buttonHeight"),
                press: function (oEvent) {
                    oControl.fireClick({
                        buttonValue : buttonValue
                    });
                }
            }).addStyleClass("virtualKeyboardButton " + styleClassName);
            return oBtn;
        },

        disableButton : function (buttonName) 
        { 
            // this.getAggregation(<any button aggregation>) returns "null"
            // this.getAggregation("_layout") returns the MatrixLayout-Aggregation
            this.getAggregation(buttonName).setEnabled(false);
        },

        renderer : {

            render : function(oRm, oControl) {                  

                oRm.write("<div");
                oRm.writeControlData(oControl);
                oRm.addStyle("width", oControl.getWidth());
                oRm.addStyle("margin-left", "44px");
                oRm.writeStyles();
                oRm.write(">");

                oRm.renderControl(oControl.getAggregation("_layout"));

                oRm.write("</div>");
            }
        }
    });


    de.vw.timerec.controls.VirtualKeyboard.prototype.exit = function () {

    };

}());
(函数(){
“严格使用”;
declare(“de.vw.timerec.controls.VirtualKeyboard”);
$.sap.includeStyleSheet(“css/VirtualKeyboard.css”);
jQuery.sap.require(“sap.ui.commons.Button”);
extend(“de.vw.timerec.controls.VirtualKeyboard”{
//控制API:
元数据:{
特性:{
/*业务对象属性*/
“title”:{type:“string”},
“宽度”:{type:“sap.ui.core.CSSSize”,defaultValue:“253px”},
“buttonWidth”:{type:“sap.ui.core.CSSSize”,defaultValue:“57px”},
“buttonHeight”:{键入:“sap.ui.core.CSSSize”,默认值:“57px”}
},
聚合:{
“_布局”:{键入:“sap.ui.commons.layout.MatrixLayout”,多个:false,可见性:“hidden”},
“_btn1”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btn2”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btn3”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btnDel”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btn4”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btn5”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btn6”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btnAlpha”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btn7”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btn8”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btn9”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btnBack”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btn0”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btnComma”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”},
“_btnMinus”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“public”},
“btnNext”:{键入:“sap.ui.commons.Button”,多个:false,可见性:“hidden”}
},
协会:{},
事件:{
单击:{enablePreventDefault:true}
}
},
init:function(){
var-oControl=这个;
var oMatrixLayout;
变量oBtn1、oBtn2、oBtn3、oBtnDel、oBtn4、oBtn5、oBtn6、oBtnAlpha、,
oBtn7、oBtn8、oBtn9、oBtnBack、oBtn0、oBtnComma、oBtnMinus、obtnext;
oMatrixLayout=新建sap.ui.commons.layout.MatrixLayout({
id:this.getId()+“-matrixLayout”,
布局固定:正确,
栏目:4,
宽度:“100%”
});
此.setAggregation(“_布局”,oMatrixLayout);
oBtn1=此项。_createButton(“1”、“1”、oControl,true);
此.setAggregation(“_btn1”,oBtn1);
oBtn2=此项。_createButton(“2”,“2”,oControl,true);
此.setAggregation(“_btn2”,oBtn2);
oBtn3=此按钮。_createButton(“3”,“3”,oControl,true);
此.setAggregation(“_btn3”,oBtn3);
oBtnDel=this.\u createButton(“,“delete”,oControl,false);
oBtnDel.setIcon(“sap-icon://undo");
这个集合(“_btnDel”,oBtnDel);
oMatrixLayout.createRow(oBtn1、oBtn2、oBtn3、oBtnDel);
oBtn4=此按钮。_createButton(“4”,“4”,oControl,true);
此.setAggregation(“_btn4”,oBtn4);
oBtn5=此按钮。_createButton(“5”,“5”,oControl,true);
此.setAggregation(“_btn5”,oBtn5);
oBtn6=此按钮。_createButton(“6”,“6”,oControl,true);
此.setAggregation(“_btn6”,oBtn6);
oBtnAlpha=此项。_createButton(“Alpha”、“Alpha”、oControl、false);
这个集合(“_btnAlpha”,oBtnAlpha);
oMatrixLayout.createRow(oBtn4、oBtn5、oBtn6、oBtnAlpha);
oBtn7=此按钮。_createButton(“7”,“7”,oControl,true);
此.setAggregation(“_btn7”,oBtn7);
oBtn8=此项。_createButton(“8”、“8”、oControl,true);
此.setAggregation(“_btn8”,oBtn8);
oBtn9=此项。_createButton(“9”,“9”,oControl,true);
此.setAggregation(“_btn9”,oBtn9);
oBtnBack=this.\u createButton(“,“back”,oControl,false);
oBtnBack.setIcon(“sap-icon://arrow-top");
此.setAggregation(“_btnBack”,oBtnBack);
oMatrixLayout.createRow(oBtn7、oBtn8、oBtn9、oBtnBack);
oBtn0=该值。_createButton(“0”、“0”、oControl,true);
此.setAggregation(“_btn0”,oBtn0);
oBtnComma=this.\u createButton(“,”,“,”,oControl,true);
此.setAggregation(“\u btnCo