SAPUI5 - 聚合绑定中的表达式绑定类型

时间:2016-10-17 03:27:33

标签: sapui5

是否可以在聚合类型绑定中使用表达式绑定。我有一个表,表中的每一行都有一个具有sap.m.Select控件的列。我想根据行的属性将每行中的select控件绑定到不同的项目。

以下是我的示例示例:

<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"
         }
      ]
   }
}

1 个答案:

答案 0 :(得分:3)

不,动态绑定路径是不可能的。但是有一些可行的解决方法:

  • 您可以处理模型数据并将相应选择项列表的引用添加到每一行。在选择字段绑定中使用该引用的相对绑定路径。

  • 您可以使用factory function创建表格的行。您可以将行模板dependant放到表中并克隆它并为工厂函数中的每一行配置选择绑定

  • 您可以使用不同的绑定向表中添加多个选择,并通过绑定选择的visible属性来隐藏每行中的所有选项。