Skip to Content
-1
Jul 09, 2020 at 10:46 PM

¿How to get control using byId in fragment handler?

108 Views Last edit Jul 09, 2020 at 10:46 PM 2 rev

Hi all,

I am working on a SAPUI5 application. I have an XML view that contains an XML fragment. The snippet contains some components like buttons, input fields and a table. When I access the snippet display, I need to call an oDATA service and load the information into the table. The problem is in the fragment's handler, I get an error accessing the table using its ID.

sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/ui/model/json/JSONModel",
	"sap/m/MessageToast"
], function (Controller, JSONModel, MessageToast) {
	"use strict";
	var oView;
	return Controller.extend("xxx.xxxxxx.controller.Fragment", {
		onInit: function () {
		},
		onAfterRendering: function () {
		},
		onClick: function (oEvent) {
		},
		constructor: function (oArg) {
			this.oParent = oArg;
			var oTable = this.oParent.byId("tableTest");
			console.log(oTable);
			return Controller.call(this);
		}
	});
});

Output: undefined

¿Can anyone help me how to get control using byId in fragment handler?

Thank.

Best regards,

Cleyderman