7

setText doesn't work in attachRequestCompleted

 6 months ago
source link: https://community.sap.com/t5/technology-q-a/settext-doesn-t-work-in-attachrequestcompleted/qaq-p/13617205
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

setText doesn't work in attachRequestCompleted

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:

UlisesCasal_0-1708699381855.png

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK