on 02-23-2024 2:45 PM
Hello everyone!!, I’m developing in sapui5 and I want to be able to setText to an element of my View, but when I run it, it gives me the following error:
The code below:
_onObjectMatched: function(oEvent) {
var oModel = new JSONModel(
sap.ui.require.toUrl("Ejercicio1Tabla/jg.json")
);
this.getView().setModel(oModel, "jg");
var cc = oEvent.getParameter("arguments").equipo1;
var cc1 = oEvent.getParameter("arguments").equipo2;
var textId1 = this.getView().byId("tl");
var strTitle = 'Jugadores del encuentro ' + cc + ' VS ' + cc1;
textId1.setText(strTitle);
var jugadores = [];
var that = this;
oModel.attachRequestCompleted(function() {
var data = oModel.getData();
data.jg.forEach(function(partido) {
if (partido.local === cc && partido.visitante === cc1) {
jugadores.push(partido.jugador1);
jugadores.push(partido.jugador2);
jugadores.push(partido.jugador3);
}
});
var txtJugadores = that.getView().byId("tx1");
txtJugadores.setText(jugadores);
});
}
Regards
Hi,
as already pointed out, you didn't fetch the element with that
that.getView().byId("tx1");
Can you share how your view looks like?
Best,
Edrilan Berisha
SAP S/4HANA Cloud Financials Development
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
72 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.