-1
我想要绑定瓷砖菜单,但我遇到了绑定选择的问题。我有一个JSON结构:绑定数据JSON SAPUI5(瓷砖菜单)
{
"module":{
"module":[
{
"id": "0",
"name": "Kepesertaan"
},
{
"id": "1",
"name": "Layanan dan Manfaat"
},
{
"id": "2",
"name": "Investasi"
},
{
"id": "3",
"name": "Perbendaharaan"
},
{
"id": "4",
"name": "Aktuaria"
}
],
"system":[
{
"id": "5",
"name": "Pengumuman"
}
]
}
}
控制器:
onInit: function(oEvent){
var oModel = new JSONModel("metroui/module.json");
this.getView().setModel(oModel);
},
pressTileModule : function(oEvent){
var sPath = oEvent.getSource().getBindingContext().getPath();
var oModel = this.getView().getModel();
var oContext = oModel.getProperty(sPath);
}
XML:
<core:View xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:l="sap.ui.layout"
xmlns:tnt="sap.tnt"
controllerName="metroui.MetroUI"
xmlns:html="http://www.w3.org/1999/xhtml">
<App id="navCon">
<pages>
<Page id="module" showHeader="false">
<Panel headerText="Module">
<content>
<l:HorizontalLayout
id="TileContainerModule"
allowWrapping="true"
content="{/}">
<GenericTile class="sapUiTinyMarginBegin sapUiTinyMarginTop tileLayout"
header="{name}" press="pressTileModule">
<tileContent>
<TileContent>
<content>
<ImageContent description="{id}" src="sap-icon://list"/>
</content>
</TileContent>
</tileContent>
</GenericTile>
</l:HorizontalLayout>
</content>
</Panel>
</Page>
</pages>
</App>
</core:View>
用于结合目标模块>模块(来自JSON),在内容的XML文件中设置=” {/模块/模块}“但我想设置内容路径JSON 在控制器,因为我想设置条件绑定,有时我只想绑定模块>模块或绑定模块>系统(从J SON结构)。如何在加载JSON文件时绑定选择?如果我将JSON结构放在控制器中,我可以创建新的JSON模型this.module.module或this.module.system,并在XML中设置content =“{/}”,但是当我加载文件JSON时我无法选择绑定。如何解决这个问题呢?
感谢, 鲍比