【发布时间】:2016-10-15 06:43:39
【问题描述】:
我在获取listItem 的绑定上下文时遇到了问题
这是我的数据模型:
{
"Items": [
{
"ItemTypeID": "0",
"Name": "A"
},
{
"ItemTypeID": "1",
"Name": "B"
},
{
"ItemTypeID": "2",
"Name": "C"
}
]
}
我的看法:
<List id="idItemTypes" mode="SingleSelectMaster" select="handleListSelect"
items="{itemTypes>/ItemTypes}">
<items>
<StandardListItem title="{itemTypes>Name}" type="Navigation" />
</items>
</List>
我的视图工作正常,并显示了我模型中的所有项目。但是,如果我从列表中选择一个项目,我将无法获得绑定上下文。它一直是未定义的。
我的控制器:
handleListSelect : function(oEvent) {
this._showDetail(oEvent.getParameter("listItem"));
},
_showDetail : function(oItem) {
this.getRouter().navTo("Items", {
console.log( oItem.getBindingContext() ); //undefined
ItemTypeID : oItem.getBindingContext().getProperty("ItemTypeID")
});
}
【问题讨论】:
-
这能回答你的问题吗? getBindingContext() returns undefined
标签: javascript data-binding sapui5