Sto lavorando a un splitapp
.UI5 SAP - getBindingContext() undefined (splitapp)
Selezionando una voce dall'elenco, si dice
Uncaught TypeError: Cannot read property 'getPath' of undefined
Master.controller.js
onSelect : function(oEvent) {
this.showDetail(oEvent.getParameter("listItem") || oEvent.getSource());
},
showDetail : function(oItem) {
var bReplace = jQuery.device.is.phone ? false : true;
this.getRouter().navTo("detail", {
from: "master",
entity: oItem.getBindingContext().getPath().substr(1),
tab: this.sTab
}, bReplace);
}
sto associazione di un JSON Model
alla lista.
oItem.getBindingContext()
non è definito. Quindi credo che il problema sia legato al contesto vincolante.
Il codice per la lista in Master.view.xml è come sotto
<content>
<List
id="list"
select="onSelect"
mode="SingleSelect"
noDataText="{i18n>masterListNoDataText}"
growing="true"
growingScrollToLoad="true"
items="{data>/results}">
<items
id="masterList">
<ObjectListItem
id="listItem"
press="onSelect"
type="{device>/listItemType}"
counter="0"
title="{data>PROJECTNAME}"
number="{data>REVENUE}"
numberUnit="{data>CURRENCY}"
markFavorite="false"
markFlagged="false"
showMarkers="true">
</ObjectListItem>
</items>
</List>
</content>
Ho impostato il modello Component.js come di seguito:
var oModel= new sap.ui.model.json.JSONModel();
oModel.loadData("Data.json");
this.setModel(oModel,"data");
La lista è visualizzato ma quando seleziono l'elemento si genera l'errore.
Ha funzionato bene. :) – FEBzX
@FEBzX, felice di aiutarti :) – Rayon