2017-05-05 53 views
0

使用公開可用的Nortwhind的OData V2服務,我可以在一個正常的sap.m.Table的產品和供應商實體擴大使用下面的代碼:SAPUI5智能表擴大

<Table 
    id="table" 
    width="auto" 
    class="sapUiResponsiveMargin" 
    items="{ 
     path: '/Products', 
     parameters : { expand: 'Supplier' } 
    }"> 
    <columns> 
     <Column id="nameColumn"> 
      <Text 
       text="{i18n>tableNameColumnTitle}" 
       id="nameColumnTitle" /> 
     </Column> 
     <Column hAlign="End"> 
      <Text text="test" /> 
     </Column> 
    </columns> 
    <items> 
     <ColumnListItem 
      type="Navigation" 
      press="onPress"> 
      <cells> 
       <ObjectIdentifier title="{ProductName}"/> 
       <Text text="{Supplier/CompanyName}"/> 
      </cells> 
     </ColumnListItem> 
    </items> 
</Table> 

現在我怎樣才能達到同樣的使用智能表輸出?在此基礎上post我試過如下:

<sap.ui.comp.smarttable:SmartTable 
    xmlns:sap.ui.comp.smarttable="sap.ui.comp.smarttable" 
    tableType="ResponsiveTable" 
    header="Smart Table" 
    enableAutoBinding="true" 
    entitySet="Products" 
    initiallyVisibleFields="ProductName" 
    tableBindingPath="Supplier"/> 

但它無法正常工作。有什麼建議麼?

回答

0

我已經向前邁進了一步。我加入以下代碼:

onBeforeRebind: function(oEvent) { var mBindingParams = oEvent.getParameter("bindingParams"); 
mBindingParams.parameters["expand"] = "Supplier"; }, 

嗯,這是它如何使用$擴大Smarttables

有沒有辦法從其他實體顯示的列?

只能通過NavigationProperty。你需要延長你的智能表列如下所述:

<smartTable:SmartTable 
     entitySet="Products" 
     tableType="ResponsiveTable" 
     header="Products" showRowCount="true" 
     enableAutoBinding="true" 
     class="sapUiResponsiveContentPadding"> 
     <Table> 
      <columns> 
       <Column width="100px" hAlign="Left"> 
        <customData> 
         <core:CustomData key="p13nData" 
          value='\{"columnKey": "p13nDataKey", "columnIndex":"4", "leadingProperty": "Supplier"}' /> 
        </customData> 
        <Text text="{/#Supplier/Name/@sap:label}" /> 
       </Column> 
      </columns> 
      <items> 
       <ColumnListItem> 
        <cells> 
         <Text 
          text="{Supplier/Name}" /> 
        </cells> 
       </ColumnListItem> 
      </items> 
     </Table> 
    </smartTable:SmartTable> 
0

我已經向前邁進了一步。我添加了下面的代碼:

onBeforeRebind: function(oEvent) { 
var mBindingParams = oEvent.getParameter("bindingParams"); 
    mBindingParams.parameters["expand"] = "Supplier"; 
}, 

哪些腳踢在beforeRebindTable事件上。它觸發在後端設置獲取擴展實體。問題是,我仍然只能看到來自第一個實體的列,因爲它是在entitySet參數中指定的。有什麼方法可以顯示其他實體的列嗎?