1

I have a UI5 app constructed from index.html. I insert the app at body like this:

<html>
  <head>
    <!-- ... -->
    <script>
      sap.ui.getCore().attachInit(function () {
        new sap.ui.core.ComponentContainer({
          name: "cvg.myApp"
        }).placeAt("content");
      });
    </script>
  </head>
  <body class="sapUiBody sapUiSizeCozy" id="content"></body>
</html>

Then in the main.view.xml, I create a basic MVC view with an empty splitter.

<mvc:View controllerName="cvg.myApp.controller.main"
  xmlns:mvc="sap.ui.core.mvc"
  xmlns:layout="sap.ui.layout">
  <layout:Splitter id="splitter" height="100vh" orientation="Horizontal">
    <!-- ... -->
  </layout:Splitter>
</mvc:View>

Now, in the main controller onInit among other things, I try to insert content areas to my splitter.

var tableSettings = {
  entitySet: "projectSet",
  tableType: "ResponsiveTable",
  useExportToExcel: true,
};
var leftTable = new sap.ui.comp.smarttable.SmartTable("taskTable", tableSettings);
var rightTable = new sap.m.HBox("dataView", {});
var oSplitter = this.getView().byId("splitter");
oSplitter.insertContentArea(rightTable, 0);
oSplitter.insertContentArea(leftTable, 0)

Now I try to access the content areas and assign a model (previously defined) specifically to the "taskTable", but the control with the ID "taskTable" is not accessible:

var oTaskTable = this.getView().byId("taskTable"); // returns: undefined
oTaskTable.setModel(taskModel);

oTaskTable remains undefined.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
JohannC
  • 31
  • 1
  • 8
  • 2
    Replace `"taskTable"` with `this.createId("taskTable")` when creating the SmartTable. By doing so, the control will be accessible via `this.byId` (or `this.getView().byId`) as mentioned in the linked answer above. – Boghyon Hoffmann May 17 '21 at 13:23

0 Answers0