我有这个 XML 列表:
<List id="myList"
items="{/Items}">
<items>
<ObjectListItem title="{ID}" type="Active" press="onListItemPressed"
number="{ parts:[{path:'Price'},{path:'Currency'}],
type: 'sap.ui.model.type.Currency', formatOptions: {showMeasure: false} }"
numberUnit="{Currency}">
<firstStatus>
<ObjectStatus
text="{path:'End',
formatter: '.formatter.getCountdown'}"
state="{path:'End', formatter:
'.formatter.getCountdownStatus'}" />
</firstStatus>
<attributes>
<ObjectAttribute text="{i18n>GlobalType}: {Format}" />
</attributes>
</ObjectListItem>
</items>
</List>
目前我用JS绑定(bind)数据:
var objectTemplate = new sap.m.ObjectListItem({
title : "{ID}",
number : "{ parts:[{path:'Price'},{path:'Currency'}], type: 'sap.ui.model.type.Currency', formatOptions: {showMeasure: false} }",
numberUnit :"{Currency}",
type : sap.m.ListType.Active,
press : this.onListItemPressed,
attributes : [new sap.m.ObjectAttribute({
text : "{i18n>GlobalType}: {Format}"
})],
firstStatus : new sap.m.ObjectStatus({
text : "{path:'End'}",
status : "{path:'End'}"
})
});
oList.bindAggregation("items", {
path : "/Items",
filters: [ new sap.ui.model.Filter("Type", sap.ui.model.FilterOperator.EQ, oArgs.TypeID ) ],
template : objectTemplate
});
我想使用 XML 列表而不是通过 JS 创建列表。我可以将bindAggregation 与XML 模板一起使用吗?
最佳答案
您在第一个 XML View 示例中以正确的方式执行此操作(您必须绑定(bind)本示例中完成的 items
属性)。
但在这种情况下,您必须删除 <items>
因为您想要使用模板工厂而不是手动定义项目,所以从 XML View 中选择节点。
<List id="myList"
items="{/Items}">
<ObjectListItem title="{ID}" type="Active" press="onListItemPressed"
number="{ parts:[{path:'Price'},{path:'Currency'}],
type: 'sap.ui.model.type.Currency', formatOptions: {showMeasure: false} }"
numberUnit="{Currency}">
<firstStatus>
<ObjectStatus
text="{path:'End',
formatter: '.formatter.getCountdown'}"
state="{path:'End', formatter:
'.formatter.getCountdownStatus'}" />
</firstStatus>
<attributes>
<ObjectAttribute text="{i18n>GlobalType}: {Format}" />
</attributes>
</ObjectListItem>
</List>
关于javascript - SAPUI5:数据绑定(bind)到列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37992720/