我们可以将 ManagedObject 绑定到 View 吗? [英] Can we bind the ManagedObject to View?

查看:44
本文介绍了我们可以将 ManagedObject 绑定到 View 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我准备了一个对象,它通过扩展 管理对象

I have prepared a object which by extending ManagedObject

并且我已将这些添加到控制器中视图的 JSONModel 中

and I have added these into the JSONModel of the view in controller as

var model = new JSONModel({
    data : someOne.getManagedObjects()
});

如何绑定这些来查看?这些我都试过了

How to bind these to view? I have tried these

1:

2:

<List id="mainLayerList"
                    selectionChange="onSelectionChange" 
                    mode = "MultiSelect"
                    items="{
                    path: '/data',
                    factory: '.dataListItemFactory'
                }">

未获取视图中的数据.

我们可以将 ManagedObject 绑定到视图吗?

Can we bind the ManagedObject to the view?

推荐答案

您可以绑定到任何 Javascript 对象.但是您只能在绑定对象上使用属性和属性.所以你不能调用像 getName() 这样的函数.

You can bind to any Javascript object. But you can only use attributes and properties on the bound objects. So you can't call functions like getName().

ManagedObjects 如何处理您在元数据中声明的属性?它创建 getXxx()setXxx() 方法并将数据 xxx 存储在私有对象内的某处.这就是为什么你不能绑定到 {xxx} 即使你已经在 ManagedObject 上声明了一个 xxx 属性.

What do ManagedObjects do with the properties you declared in the metadata? It creates getXxx() and setXxx() methods and stores the data xxx somewhere inside a private object. Thats why you cant bind to {xxx} even though you have declared a xxx property on the ManagedObject.

作为一种解决方法,您可以创建getter 属性setter 属性您要绑定到的所有属性的 ManagedObject:

As a workaround you could create getter properties and setter properties on your ManagedObject for all attributes you want to bind to:

get xxx()  { return this.getXxx();} 
set xxx(value) { this.setXxx(value);} 

这篇关于我们可以将 ManagedObject 绑定到 View 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆