2016-09-20 48 views
0

簡單的問題。我是SAP Fiori的初學者,嘗試從Web IDE SAP Fiori創建的表中檢索值。但我不成功。有人提示如何到達那裏?SAP Fiori從表中獲得價值

<Table id="table0" items="{/Entity1_Set}" noDataText="Drop column list items here and columns in the area above"> 
        <items><ColumnListItem counter="0" id="item1" detailPress="onShowHello" press="" type="DetailAndActive"> 
          <cells> 
           <Text id="text5" maxLines="0" text="{Id}"/> 
           <Text id="text6" maxLines="0" text="{field1}"/> 
           <Text id="text7" maxLines="0" text="{field2}"/> 
           <Text id="text8" maxLines="0" text="Euro"/> 
          </cells> 
         </ColumnListItem> 
        </items> 
        <columns> 
         <Column id="column0"> 
          <header> 
           <Label id="label0" text="Floor"/> 
          </header> 
         </Column> 

.JS控制器

sap.ui.define([ 「SAP/UI /核心/ MVC /控制器」 ],功能(控制器){ 「使用嚴格」;

return Controller.extend("QuickStartApplication.controller.View1", { 
    onShowHello: function(){ 
     sap.m.MessageToast.show("Hello World!"); 
    } 
}); 

});

在hello world中,我想顯示錶格中字段的值。

謝謝。

回答

0

您可以在函數中傳遞參數,該函數在事件中調用。 請參閱https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.m.ListItemBase.html#event:detailPress

使用這些參數,您可以訪問綁定數據。 請參閱如何讀取ColumnListItem的綁定上下文下面的代碼:

detailPress : function(oEventParams){ 
       var oListItem = oEventParams.getSource(); 
       var oBindingContext = oListItem.getBindingContext(); var sSomePropertyValue = oBindingContext.getProperty("<nameOfProperty>"); } 

使用.getProperty,您可以訪問您的字段值。

+0

謝謝你的幫助。 –