聚合从JSON文件绑定SAPUi5

时间:2018-07-16 23:48:28

标签: sapui5

我是使用SAP UI5的实习生,并且在访问JSON文件中的数据到表时遇到困难 我的JSON数据的格式如下(这是一个代码段):

[   
      {
      "id": 0,
      "name": "<UNKNOWN>",
      "area": "core",
      "cmakeComponents": [
         {
            "id": "RemoteSupportDaemon",
            "name": "RemoteSupportDaemon"
         }
       ],
       ......
      },
      {
      ........
      }

]

我正试图从manifest.json文件中加载JSON文件:

            "models": {
        "i18n": {
            "type": "sap.ui.model.resource.ResourceModel",
            "settings": {
                "bundleName": "opensap_DashAnalytics.i18n.i18n"
            }
        },
        "data": {
            "type": "sap.ui.model.json.JSONModel",
            "uri": "model/component_XXX.json"
        },
        "component": {
            "type": "sap.ui.model.json.JSONModel",
            "uri": "model/component_SSS.json"
        }
    }

我正尝试在我的视图中使用该数据制作具有以下内容的表:

                    <!--sap.m.table-->
                <Table
                id="idTable"
                items= "{path:'{data>/}',
                        mode: 'sap.ui.model.BindingMode.OneWay'}"
               .....
                >
                    <headerToolbar>
                        <Toolbar>
                            <Title text="Orange"/>
                        </Toolbar>
                    </headerToolbar>
                    <columns>
                        <Column>
                            <Text text="Component" />
                        </Column>
                        <Column>
                            <Text text="Number of failed Tests" />
                        </Column>
                        <Column>
                            <Text text="Number of Bugs" />
                        </Column>
                        <Column>
                            <Text text="Total Tests" />
                        </Column>
                        <Column>
                            <Text text="Pass/Fail Ratio" />
                        </Column>
                    </columns>
                    <items>
                        <ColumnListItem         
                        press= "onItemSelected"
                        type= "Navigation">
                            <cells>
                                <ObjectListItem title="{data>name}"/>   
                            </cells>
                           .........
                           .........
                        </ColumnListItem>
                    </items>
                </Table>

运行代码时,我的表没有显示数据

我假设问题必须处理如何编写路径变量或相关内容。 我想知道是否有人会对此问题有所帮助。

1 个答案:

答案 0 :(得分:2)

表“项”聚合中的语法错误

<Table
  id="idTable"
  items= "{path:'data>/',
  mode: 'sap.ui.model.BindingMode.OneWay'}"
>

此外,请记住,单元格的数量应该与要正常工作的列数相同

<cells>
  <ObjectListItem title="{data>name}"/>  
  <ObjectListItem title="{data>otherProperty1}"/>  
  <ObjectListItem title="{data>otherProperty2}"/>  
  <ObjectListItem title="{data>otherProperty3}"/>  
  <ObjectListItem title="{data>otherProperty4}"/>   
</cells>
相关问题