Get Selected Item Details

拜拜、爱过 提交于 2019-12-21 21:18:02

问题


I am using the sap.m.ObjectListItem as my list items to which I have bound JSON data from an API. However, I can't find a way to get the selected item from the list when I press on an item. Even getting the key of that item would be helpful.

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

回答1:


The following should be placed in your respective controller (but I guess you already have implemented something similar)

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");
}

Hope that helps



来源:https://stackoverflow.com/questions/35477832/get-selected-item-details

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!