Skip to Content

Get control by Id from block

Hi all, does anyone know how I can get a sapui5 control (viz) declared in a xml block from js block ? I tried with sapui.getCore ().byId (), this.getView (). byId (), but does not work

ABlock.xml

<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns:layout="sap.ui.layout" xmlns:forms="sap.ui.layout.form" xmlns="sap.m" xmlns:viz="sap.viz.ui5.controls" >

<viz:VizFrame xmlns="sap.viz" id="idviz" >

</viz:VizFrame>

</mvc:View>

ABlock.js

jQuery.sap.declare("block.ABlock");

jQuery.sap.require("sap.uxap.BlockBase");

sap.uxap.BlockBase.extend("block.AditionalBlock", {

metadata: {

views: {

Collapsed: {

viewName: "block.ABlock",

type: "XML"

},

Expanded: {

viewName: "block.ABlock",

type: "XML"

}

}

},

onAfterRendering: function() {

var oVizFrame = sap.ui.getCore().byId("idviz"); //undefined

.......

}

});

Thanks in advance

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Apr 25, 2016 at 09:52 AM

    It seems the problem is that the framework will override the id of the control with viewId + "--" + id.

    I just had to find it (plugin UI5 in chrome) and sap.ui.getCore().byId(viewId + "--" + id).

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on 2 days ago

    Did you get any solution for this problem? I am facing the same problem.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.