在绑定使用XML列表 [英] Binding in List with XML

查看:184
本文介绍了在绑定使用XML列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望只使用XML绑定列表,以一个JSON文件的数据。

I want to use only XML to bind a list to the data of a JSON file.

下面是我的code:

XML查看:

<List
    headerText="Positions"
    items="{/Positions}">
    <ObjectListItem
        title="{positions>id}">
    </ObjectListItem>
</List>

index.html的

index.html

var oPositionsModel = new sap.ui.model.json.JSONModel();
oPositionsModel.loadData("model/Positions.json");
sap.ui.getCore().setModel(oPositionsModel);

模型/ Positions.json

model/Positions.json

{
"Positions": [
    {
        "id": 123456,
        "article": "Abcde",
        "amount": 12
    },
    {
        "id": 654321,
        "article": "Edcba",
        "amount": 21
    }
]
}

我不明白,什么是错的。但我得到没有数据的所有时间。
有没有在控制台说有一个问题在这里。

I can't see, what's wrong. But I get "no data" all the time. There is nothing in the console saying there is a problem here.

推荐答案

您的标题结合属性是不正确的。您想直接绑定到 ID 位置的属性,无需指定型号:

Your binding for the title attribute is not correct. You want to bind it directly to the id attribute of Positions, no need to specify the model:

<List
    headerText="Positions"
    items="{/Positions}">
    <ObjectListItem
        title="{id}">
    </ObjectListItem>
</List>

在JSBin 工作演示

这篇关于在绑定使用XML列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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