【问题标题】:Aggregation binding SAPUi5 from JSON files来自 JSON 文件的聚合绑定 SAPUi5
【发布时间】:2018-07-16 23:48:27
【问题描述】:

我是一名使用 SAP UI5 的实习生,我在将 JSON 文件中的数据访问到表时遇到了困难 我的 JSON 数据格式如下(这是一个 sn-p):

[   
      {
      "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>

当我运行我的代码时,我的表格显示 NO DATA

我假设问题必须处理我如何编写路径变量或相关的东西。 我想知道是否有任何熟悉这个问题的人可以帮助我。

【问题讨论】:

    标签: sapui5


    【解决方案1】:

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

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-24
      • 1970-01-01
      • 2016-11-29
      • 2018-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多