2016-08-30 73 views
1

数据模型绑定:如何嵌套一个模型,视图与SAPUI5

[{ 
    "id": 51, 
    "name": "BuildingA", 
    "floors": [{ 
     "id": 101, 
     "name": "UG" 
    }, { 
     "id": 102, 
     "name": "EG" 
    }, { 
     "id": 103, 
     "name": "1" 
    }, { 
     "id": 104, 
     "name": "2" 
    }, { 
     "id": 105, 
     "name": "3" 
    }, { 
     "id": 106, 
     "name": "4" 
    }] 
}, { 
    "id": 52, 
    "name": "BuildingB", 
    "floors": [] 
}] 

数据绑定在控制器:

this.getView().setModel(oResponseModel, "buildingNavigation"); 

数据鉴于绑定:

<tnt:NavigationList items="{path: 'buildingNavigation>/'}"> 
    <tnt:NavigationListItem text="{buildingNavigation>name}" icon="sap-icon://building" expanded="true" items="{path: 'buildingNavigation>floors', templateShareable:true}"> 
     <tnt:NavigationListItem text="{name}"> 
     </tnt:NavigationListItem> 
    </tnt:NavigationListItem> 
</tnt:NavigationList> 

我的工作导航列表here

基本上,从第一层获得建筑物名称(例如, BuildingA,BuildingB)。第二级似乎以检索适量项目的方式工作。 (如A栋,拥有6X子的水平,但我无法接收来自地面阵列的属性名称它只是显示在导航6空项

我尝试了不同的组合:。 如/buildingNavigation>floors>name

所有。相关信息包含在模型中收到我似乎只是没有找到格式正确地访问它

回答

1

内最NavigationListItem将也有模型的别名绑定

你的代码将是:。

<tnt:NavigationList items="{path: 'buildingNavigation>/'}"> 
    <tnt:NavigationListItem text="{buildingNavigation>name}" icon="sap-icon://building" expanded="true" items="{path: 'buildingNavigation>floors', templateShareable:true}"> 
     <tnt:NavigationListItem text="{buildingNavigation>name}"> 
     </tnt:NavigationListItem> 
    </tnt:NavigationListItem> 
</tnt:NavigationList>