获取所选项目详细信息

Mat*_*tts 3 sapui5

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

<List id="ObjectList"
  itemPress=".onPressDcData"
  items="{DC>/}"
>
  <ObjectListItem
    type="Active"
    title="{DC>Name}"
  />
</List>
Run Code Online (Sandbox Code Playgroud)

Mar*_*arc 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");
}
Run Code Online (Sandbox Code Playgroud)

希望有所帮助