cancel
Showing results for 
Search instead for 
Did you mean: 

Get control by Id from block

juancarlosorta
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

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

juancarlosorta
Participant
0 Kudos

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).