我有一个JSON对象如下:
{
"Routes":
{
"A":
[
{"Locality": "L1","Pickup": "Junction1","Time": "6:45AM"},
{"Locality": "L2","Pickup": "Junction2","Time": "6:48Am"},
{"Locality": "L3","Pickup": "Junction3","Time": "6:50AM"},
{"Locality": "L4","Pickup": "Junction4","Time": "6:55AM"},
{"Locality": "L5","Pickup": "Junction5","Time": "6:58AM"},
{"Locality": "L6","Pickup": "Junction6","Time": "7:00AM"}
]
,
"A1":
[
{"Locality": "K1","Pickup": "Junction1","Time": "6:45AM"},
{"Locality": "K2","Pickup": "Junction2","Time": "6:48Am"},
{"Locality": "K3","Pickup": "Junction3","Time": "6:50AM"},
{"Locality": "K4","Pickup": "Junction4","Time": "6:55AM"},
{"Locality": "K5","Pickup": "Junction5","Time": "6:58AM"},
{"Locality": "K6","Pickup": "Junction6","Time": "7:00AM"}
]
}
}
并在控制器初始化函数中将模型设置为UI5视图。
var oModel1 = new sap.ui.model.json.JSONModel("model/routes.json");
this.getView().setModel(oModel1,"tablemodel");
JSON模型存储在模型文件夹中,如上所示。
在视图中我宣布了一个表。
如何绑定所有" A1" JSON文件中存在的路由到表。我很困惑,给出了绑定行的表的路径。
答案 0 :(得分:0)
var oModel = new sap.ui.model.json.JSONModel("model/routes.json");
oTable.setModel(oModel);
oTable.bindRows("/Routes/A1");
<iframe width="100%" height="300" src="//jsfiddle.net/6qbe2Lgs/1/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>