2016-08-30 36 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>