2016-10-17 57 views
1

是否可以在Aggregation類型綁定中使用表達式綁定。我有一個表,表中的每一行都有一個有sap.m.Select控件的列。我想根據行的屬性將每行中的選擇控件與不同的項綁定在一起。SAPUI5 - Aggregation綁定中的表達式綁定類型

下面是我的樣品例如:

<Table headerText="Dimensions/Measures" mode="MultiSelect" includeItemInSelection="true" items="{path: 'dataModel>/Fields'}"> 
 
    <columns> 
 
    <Column hAlign="Center" vAlign="Center" visible="true"> 
 
     <header> 
 
     <Label text="Dimensions/Measures" /> 
 
     </header> 
 
    </Column> 
 
    <Column hAlign="Center" vAlign="Center" visible="true"> 
 
     <header> 
 
     <Label text="Type" /> 
 
     </header> 
 
    </Column> 
 
    <Column hAlign="Center" vAlign="Center" visible="true"> 
 
     <header> 
 
     <Label text="Role" /> 
 
     </header> 
 
    </Column> 
 
    </columns> 
 
    <ColumnListItem> 
 
    <Text text="{dataModel>Fieldname}" /> 
 
    <Text text="{= ${dataModel>Aggr_Oper} !== null ? 'Measure' : 'Dimension'}" /> 
 
    <Select items="{= ${path: 'dataModel>Aggr_Oper'} !== null ? ${dataModel>/chartConfigData/dimData}: ${dataModel>/chartConfigData/measData}}"> 
 
     <core:Item key="{dataModel>key}" text="{dataModel>text}" /> 
 
    </Select> 
 
    </ColumnListItem> 
 
</Table>

我的數據模型看起來如下:

{ 
 
    "Fields":[ 
 
     { 
 
     "AppID":"RP_PROP", 
 
     "AppVariantID":"PropListVariantDemo", 
 
     "Fieldname":"PropertyID", 
 
     "FieldDescription":"PropertyID", 
 
     "Aggr_Oper":null, 
 
     "Filterable":null, 
 
     "Visible":"true", 
 
     "Filter_Val":null, 
 
     "DisplayOrder":1, 
 
     "FieldGroup":null, 
 
     "SubTotal":null, 
 
     "FieldType":null, 
 
     "Sortable":"true", 
 
     "Sort_Op":"ASC", 
 
     "Sort_Order":1, 
 
     "ChartRole":null, 
 
     "BusinessEntity":"BRS" 
 
     }, 
 
     { 
 
     "AppID":"RP_PROP", 
 
     "AppVariantID":"PropListVariantDemo", 
 
     "Fieldname":"Description", 
 
     "FieldDescription":"Description", 
 
     "Aggr_Oper":null, 
 
     "Filterable":null, 
 
     "Visible":"true", 
 
     "Filter_Val":null, 
 
     "DisplayOrder":2, 
 
     "FieldGroup":null, 
 
     "SubTotal":null, 
 
     "FieldType":null, 
 
     "Sortable":"true", 
 
     "Sort_Op":null, 
 
     "Sort_Order":null, 
 
     "ChartRole":null, 
 
     "BusinessEntity":"BRS" 
 
     }, 
 
     { 
 
     "AppID":"RP_PROP", 
 
     "AppVariantID":"PropListVariantDemo", 
 
     "Fieldname":"PropertyTypeID", 
 
     "FieldDescription":"PropertyTypeID", 
 
     "Aggr_Oper":null, 
 
     "Filterable":null, 
 
     "Visible":"true", 
 
     "Filter_Val":null, 
 
     "DisplayOrder":3, 
 
     "FieldGroup":null, 
 
     "SubTotal":null, 
 
     "FieldType":null, 
 
     "Sortable":"true", 
 
     "Sort_Op":null, 
 
     "Sort_Order":null, 
 
     "ChartRole":null, 
 
     "BusinessEntity":"BRS" 
 
     }, 
 
     { 
 
     "AppID":"RP_PROP", 
 
     "AppVariantID":"PropListVariantDemo", 
 
     "Fieldname":"PropertyType", 
 
     "FieldDescription":"PropertyType", 
 
     "Aggr_Oper":null, 
 
     "Filterable":null, 
 
     "Visible":"true", 
 
     "Filter_Val":null, 
 
     "DisplayOrder":4, 
 
     "FieldGroup":null, 
 
     "SubTotal":null, 
 
     "FieldType":null, 
 
     "Sortable":null, 
 
     "Sort_Op":null, 
 
     "Sort_Order":null, 
 
     "ChartRole":null, 
 
     "BusinessEntity":"BRS" 
 
     }, 
 
     { 
 
     "AppID":"RP_PROP", 
 
     "AppVariantID":"PropListVariantDemo", 
 
     "Fieldname":"RegionID", 
 
     "FieldDescription":"RegionID", 
 
     "Aggr_Oper":null, 
 
     "Filterable":null, 
 
     "Visible":"true", 
 
     "Filter_Val":null, 
 
     "DisplayOrder":5, 
 
     "FieldGroup":null, 
 
     "SubTotal":null, 
 
     "FieldType":null, 
 
     "Sortable":null, 
 
     "Sort_Op":null, 
 
     "Sort_Order":null, 
 
     "ChartRole":null, 
 
     "BusinessEntity":"BRS" 
 
     }, 
 
     { 
 
     "AppID":"RP_PROP", 
 
     "AppVariantID":"PropListVariantDemo", 
 
     "Fieldname":"RegionDescription", 
 
     "FieldDescription":"RegionDescription", 
 
     "Aggr_Oper":null, 
 
     "Filterable":null, 
 
     "Visible":"true", 
 
     "Filter_Val":null, 
 
     "DisplayOrder":6, 
 
     "FieldGroup":null, 
 
     "SubTotal":null, 
 
     "FieldType":null, 
 
     "Sortable":null, 
 
     "Sort_Op":null, 
 
     "Sort_Order":null, 
 
     "ChartRole":null, 
 
     "BusinessEntity":"BRS" 
 
     } 
 
    ], 
 
    "chartConfigData":{ 
 
     "dimData":[ 
 
     { 
 
      "key":"val1", 
 
      "text":"val1" 
 
     }, 
 
     { 
 
      "key":"val2", 
 
      "text":"val2" 
 
     } 
 
     ], 
 
     "measData":[ 
 
     { 
 
      "key":"val3", 
 
      "text":"val3" 
 
     }, 
 
     { 
 
      "key":"val4", 
 
      "text":"val4" 
 
     } 
 
     ] 
 
    } 
 
}

回答

2

沒有,動態綁定路徑s是不可能的。有一些可能的解決方法但是:

  • 您可以處理您的模型數據,並添加一個參照適當選擇項目列表中的每一行。在選擇字段綁定中使用該引用的相對綁定路徑。

  • 您可以使用factory function來創建表格的行。你可以把你的行模板,爲dependant你的表和克隆它,並配置選擇在工廠功能

  • 你可以用不同的綁定到你的表中的每一行中添加多個選擇隱藏所有,但每行一個結合通過綁定選擇的屬性。

+0

謝謝schnoedel。由於行數有限,所以使用上面的工廠函數選項。 – Deepak