首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SAPUI5多模绑定

SAPUI5多模绑定
EN

Stack Overflow用户
提问于 2014-11-27 09:04:01
回答 1查看 2.6K关注 0票数 2

我对多模型绑定有问题。

在控制器的init函数中,我在ui.core中设置了JSON模型

代码语言:javascript
复制
var oModel = new sap.ui.model.json.JSONModel(data1);
sap.ui.getCore().setModel(oModel, "model1");

在视图中,我有一个ColumnListItem模板,并将其绑定到一个表中

代码语言:javascript
复制
    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);

对于simple model,它的工作非常严格,但是在多模型表中,它只得到项目的数量,而不是模型的属性。有解决办法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-27 09:46:13

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

代码语言:javascript
复制
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);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27166691

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档