我已为列表项设置了全局模型,如下所示
在控制器初始化方法
中var data = {
A1: [
{"id":"1","Type":"Incidents","Ticket":"P1-P2","value":90 },
{"id":"2","Type":"Incidents","Ticket":"P1-P2","value":93 },
{"id":"3","Type":"Resolution Time PM","Ticket":"P1-P2","value":96 },
{"id":"4","Type":"Resolution Time BS","Ticket":"P1-P2","value":70 },
{"id":"5","Type":"Resolution Time SCI","Ticket":"P1-P2","value":83 },
{"id":"6","Type":"Incidents","Ticket":"P1-P2","value":90 },
{"id":"7","Type":"Incidents","Ticket":"P1-P2","value":93 },
{"id":"8","Type":"Resolution Time PM","Ticket":"P1-P2","value":96 },
{"id":"9","Type":"Resolution Time BS","Ticket":"P1-P2","value":70 },
{"id":"10","Type":"Resolution Time SCI","Ticket":"P1-P2","value":83 },
{"id":"11","Type":"Incidents","Ticket":"P1-P2","value":90 },
{"id":"12","Type":"Incidents","Ticket":"P1-P2","value":93 }]
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(data);
sap.ui.getCore().setModel(oModel,'model_tickets');
this.List_tickets.setModel(oModel);
this.List_tickets.bindAggregation("items","/A1",this.List_ticketsTemplate);
在视图中创建内容
oController.List_tickets = new sap.m.List("List_tickets",{}),
oController.List_ticketsTemplate = new sap.m.ObjectListItem("tickets",{
title : "{Type}",
number: "{value}"
press : oController.NavtoTicketDetails,
attributes : [new sap.m.ObjectAttribute({
text : "{Ticket}",
})],
Listitem的onpress事件应用导航到对象标题页,其中显示列表项的更多详细信息,其中列表的id作为属性在其他页面中的路由中传递
如何过滤所选id的全局模型并分配给对象头,基本上将对象头与所选列表项值绑定。
答案 0 :(得分:1)
你说你可以获得身份证明。然后,您应该将对象标题页绑定到所选项。 (如果您愿意,也可以专门绑定列表。)
this.getView().bindElement("model_tickets>/A1/" + id);
也不是说绑定的语法应该以命名的模型名称作为前缀:
...
title : "{model_tickets>Type}",
number: "{model_tickets>value}"
...
text : "{model_tickets>Ticket}",
希望这有帮助