Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
2,808

A control with dynamic id, for example "__component0---sap.app.view.MainView--sap.app.view.TableView--Table1", which changes in runtime and therefore this control cannot be accessed by fynction byId, can be however accessed in following way:

if for example there is the view with the table:


<mvc:View
  displayBlock="true"
  xmlns:l="sap.ui.layout"
  xmlns:table="sap.ui.table"
  xmlns:mvc="sap.ui.core.mvc"
  controllerName="sap.app.controller.TableView"
>
  <l:HorizontalLayout>
   <SearchField liveChange="onSearch"/>
  </l:HorizontalLayout>
  <table:TreeTable
    id="Table1"
    rows="{/root}"
  >
    <table:columns>
      ...
    </table:columns>
  </table:TreeTable>
</mvc:View>

then in the controller of this view (sap.app.controller.TableView) this table can be accessed by following statement:


var oTable = this.getView().getContent()[1];
oTable.expandToLevel(3);

or in other controller this table can be accessed by calling corresponding function of this controller:


expandTable: function () {
var oTable = this.getView().getContent()[1];
oTable.expandToLevel(3);
}

See How to call function of one controller from another controller for more details.

5 Comments