我正在开发一个SplitApp.它说,从列表中选择一个项目
未捕获的TypeError:无法读取未定义的属性'getPath'
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);
}
Run Code Online (Sandbox Code Playgroud)
oItem.getBindingContext()回报undefined.所以我认为问题在于绑定上下文.
<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"
/>
</items>
</List>
Run Code Online (Sandbox Code Playgroud)
var oModel= new sap.ui.model.json.JSONModel();
oModel.loadData("Data.json");
this.setModel(oModel,"data");
Run Code Online (Sandbox Code Playgroud)
将显示该列表,但是当我选择该项时,将引发错误.
Ray*_*yon 10
getBindingContext(sModelName?),获取给定模型名称的此对象的绑定上下文.如果对象没有自己设置绑定上下文并且没有自己的模型集,它将使用其父层次结构中定义的第一个绑定上下文.
您已为模型(this.setModel(oModel, "data"))指定了名称.oItem.getBindingContext('data')访问绑定上下文时指定模型名称()
尝试:
oItem.getBindingContext("myModel").getPath().substr(1)
Run Code Online (Sandbox Code Playgroud)
如果绑定模型已命名,则必须将模型的名称传递给。getBindingContext
| 归档时间: |
|
| 查看次数: |
7432 次 |
| 最近记录: |