Search code examples
javascriptsapui5

Access one controller inside another in SAPUI5


I have a SAPUI5 master detail page application. So in master page controller I need to access an element which is defined in detail view. How can I do it?

jQuery.sap.require("util.Formatter");
jQuery.sap.require("util.Networkaccess");

sap.ui.controller("view.Sales.SalesOrder.SoMaster", {
    myFunc: function() {
        var iconTabBar = this.byId('itabBar'); 
        iconTabBar.setSelectedItem(iconTabBar.getItems()[1]);
    }
})

The above code will through error because the itabBar element is not there in master view, it's defined in detail view file.


Solution

  • i am not sure i exactly know what you are trying to do, controls have unique id's prefixed by the view, you could try

    var iconTabBar = sap.ui.getCore().byId("vwDetails--itabBar")