获取所选项目详细信息

时间:2016-02-18 09:43:28

标签: sapui5

我使用sap.m.ObjectListItem作为我的列表项,我从API中绑定了JSON数据。但是,当我按下某个项目时,我找不到从列表中获取所选项目的方法。即使获得该项目的关键也会有所帮助。

<List id="ObjectList"
  itemPress=".onPressDcData"
  items="{DC>/}"
>
  <ObjectListItem
    type="Active"
    title="{DC>Name}"
  />
</List>

1 个答案:

答案 0 :(得分:8)

以下内容应放在各自的控制器中(但我猜你已经实现了类似的东西)

onPressDcData: function(oEvent) {
    // The actual Item
    var oItem = oEvent.getSource();
    // The model that is bound to the item
    var oContext = oItem.getBindingContext("DC");
    // A single property from the bound model
    var sName = oContext.getProperty("Name");
}

希望有所帮助

相关问题