如何检查是否呈现UI5控件?

问题描述 投票:0回答:1

我在FlexColumnLayout内的特定控件上打开一个弹出窗口。根据屏幕尺寸,一旦中间列展开,它将不会呈现。

我想在打开popover之前检查控件是否呈现,但我似乎无法找到允许它的属性。

已经尝试过这篇文章的解决方案:Check if a control is currently rendered and visible

enter image description here

如果您想在实际代码中进行测试,只需使用Flex列布局的演示应用程序,并尝试在展开开始列时在其中一个隐藏按钮上打开弹出窗口。

谢谢你的帮助,埃里克

编辑27.08.18(有问题的代码):

控制器:

/**
* Listner. Triggered when help is canceled.
* Closes popover.
* @author WN00096217 (Eric Schuster)
* @memberof xxxxxxxxxxxx
* @function onHelpCancel
*/
onHelpCancel: function () {
    var iHelp = this._oHelpModel.getProperty("/counter");
    this._oHelpModel.setProperty("/counter", 0);
    this._oHelpModel.getProperty("/p" + iHelp).close();
},

/**
 * Listner. Triggered when help is continue.
 * Closes popover, opens next popover.
 * @author WN00096217 (Eric Schuster)
 * @memberof xxxxxxxxxxxxxxxxxxx
 * @function onHelpNext
 */
onHelpNext: function () {
    var iHelp = this._oHelpModel.getProperty("/counter");
    this._oHelpModel.setProperty("/counter", iHelp + 1);
    this._oHelpModel.getProperty("/p" + iHelp).close();
    this._oHelpModel.getProperty("/p" + (iHelp + 1)).openBy(this._oHelpModel.getProperty("/c" + (iHelp + 1)));
},

控制器(innit的一部分):

this._oHelpModel.setProperty("/c0", this._oView.byId("xxxxx"));
this._oHelpModel.setProperty("/c1", this._oView.byId("xxxx"));
this._oHelpModel.setProperty("/c2", this._oView.byId("xxxxx"));
this._oHelpModel.setProperty("/c3", this._oView.byId("xxxxxx"));
this._oHelpModel.setProperty("/c4", this._oView.byId("xxxxxx"));
this._oHelpModel.setProperty("/c5", this._oView.byId("xxxxx"));
this._oHelpModel.setProperty("/c6", this._oView.byId("xxxxx"));
this._oHelpModel.setProperty("/c7", this._oView.byId("xxxxxx"));
this._oHelpModel.setProperty("/c8", this._oView.byId("xxxxx"));

组件(innit的一部分):

//p eq popover c eq controll
var oHelpModel = new JSONModel({
    counter: 0,
    p0: null,
    c0: null,
    p1: null,
    c1: null,
    p2: null,
    c2: null,
    p3: null,
    c3: null,
    p4: null,
    c4: null,
    p5: null,
    c5: null,
    p6: null,
    c6: null,
    p7: null,
    c7: null,
    p8: null,
    c8: null
});
this.setModel(oHelpModel, "helpModel");

我喜欢的控制器看起来像:

/**
 * Listner. Triggered when help is continue.
 * Closes popover, opens next popover.
 * @author WN00096217 (Eric Schuster)
 * @memberof xxxxxxxxxxxxxxxxx
 * @function onHelpNext
 */
onHelpNext: function () {
    var iHelp = this._oHelpModel.getProperty("/counter");
    if("control is rendered"){
        this._oHelpModel.setProperty("/counter", iHelp + 1);
        this._oHelpModel.getProperty("/p" + iHelp).close();
        this._oHelpModel.getProperty("/p" + (iHelp + 1)).openBy(this._oHelpModel.getProperty("/c" + (iHelp + 1)));
    } else {
        this._oHelpModel.setProperty("/counter", iHelp + 1);
        this.onHelpNext();
        return;
    }
},
sapui5 rendering popover
1个回答
2
投票

使用控件的onAfterRendering事件。在你对应的视图中的controller

var oControl = this.byId("yourControl");

oControl.addEventDelegate({
    onAfterRendering: function() {

        // your confirmation that the control is rendered

    }
}

经过澄清后更新:

如果它还没有id,则给控件一个id。通过其ID获得控制权。检查控件是否处于活动状态。在相应视图的控制器中:

var oControl = this.byId("yourControl");

oControl.isActive(); // true if the control is visible
© www.soinside.com 2019 - 2024. All rights reserved.