model-binding - SAPUI5 多模型绑定(bind)

标签 model-binding sapui5

我在多模型绑定(bind)方面遇到问题。

在 Controller 的 init 函数中,我在 ui.core 中设置 JSON 模型

var oModel = new sap.ui.model.json.JSONModel(data1);
sap.ui.getCore().setModel(oModel, "model1");

在 View 中,我有一个 ColumnListItem 模板,并将其绑定(bind)在表中

    var template = new sap.m.ColumnListItem({
          id: "first_template",
          type: "Navigation",
          type : sap.m.ListType.Active,
          visible: true,
          selected: true,
          cells: [ new sap.m.Label({
                    text: "{name}"
                    })
          ],
          press: [oController.pressListMethod]


  });

   oTable.bindItems("model1>/events", template, null, null);
   oPage.addContent(oTable);

对于简单模型,它的工作原理是正确的,但在多模型表中只能获取项目数,但不能获取模型的属性。有什么解决办法吗?

最佳答案

您还需要在模板中使用模型名称:

var template = new sap.m.ColumnListItem({
  id: "first_template",
  type: "Navigation",
  type : sap.m.ListType.Active,
  visible: true,
  selected: true,
  cells: [ 
    new sap.m.Label({
      text: "{model1>name}" // No leading "/" here since the binding is relative to the aggregation binding below
    })
  ],
  press: oController.pressListMethod
});

oTable.bindItems("model1>/events", template);
oPage.addContent(oTable);

关于model-binding - SAPUI5 多模型绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27166691/

相关文章:

asp.net-mvc - ASP.NET MVC 模型绑定(bind)子对象

c# - 覆盖 ModelState 非常技术性的错误消息

java - 从 Java servlet 获取 SAPUI5 中的 session 数据

sapui5 - 如何去掉 UI5 路由中 URL 中的哈希符号 (`#` )?

javascript - sap.m.PlanningCalendar : How to hide or skip weekends

c# - Web API 操作参数间歇性为空

asp.net-mvc - MVC3 ModelBinding 到带有索引间隙回发的集合

ASP.NET MVC 模型绑定(bind) IList<> 参数

sapui5 - 如何从 XML View 中的扩展集合绑定(bind) OData $count

javascript - 基本 openUI5 分割 View 应用程序