2017-05-05 56 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参数中指定的。有什么方法可以显示其他实体的列吗?