Javascript SAPUI5:数据绑定到列表
我有以下XML列表:Javascript SAPUI5:数据绑定到列表,javascript,xml,data-binding,sapui5,Javascript,Xml,Data Binding,Sapui5,我有以下XML列表: <List id="myList" items="{/Items}"> <items> <ObjectListItem title="{ID}" type="Active" press="onListItemPressed" number="{ parts:[{path:'Price'},{path:'Curr
<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>
我想使用XML列表,而不是通过JS创建列表。我可以将bindAggregation与XML模板一起使用吗?在第一个XML视图示例中,您使用的方法是正确的(您必须绑定在本示例中完成的
items
属性)。
但是在这种情况下,您必须从XML视图中删除
节点,因为您希望使用模板工厂而不是手动定义项
<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>
在第一个XML视图示例中,您使用的方法是正确的(您必须绑定本示例中完成的
items
属性)。
但是在这种情况下,您必须从XML视图中删除
节点,因为您希望使用模板工厂而不是手动定义项
<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>
但是我在控制器中要做什么而不是模板:objectTemplate
?我可以换成“myList”结构吗?我不知道如何在XML视图中使用bindAggregation
,也不支持/建议混合使用这两种技术;但是,您可以尝试删除JS代码的template:objectTemplate
部分,并从XML中删除items=“{/items}”
绑定和
节点。你为什么要把这些东西混在一起?如果要在XML视图中应用过滤器,请选中此复选框“我想对所有视图使用XML”。现在是混音了。在XML中是一个没有属性的空列表,在控制器中,该列表将被填充:-/是的,这是我们可以期待的,因为在绑定的情况下,混合物似乎不受支持。有了这个,我建议转到XML视图。控制器中的oList.bindAggregation(..)
相当于XML视图中的items=“{/items}”
。在这种情况下,您是否有任何阻塞/错误?但是我必须在控制器中而不是在template:objectTemplate
中执行哪些操作?我可以换成“myList”结构吗?我不知道如何在XML视图中使用bindAggregation
,也不支持/建议混合使用这两种技术;但是,您可以尝试删除JS代码的template:objectTemplate
部分,并从XML中删除items=“{/items}”
绑定和
节点。你为什么要把这些东西混在一起?如果要在XML视图中应用过滤器,请选中此复选框“我想对所有视图使用XML”。现在是混音了。在XML中是一个没有属性的空列表,在控制器中,该列表将被填充:-/是的,这是我们可以期待的,因为在绑定的情况下,混合物似乎不受支持。有了这个,我建议转到XML视图。控制器中的oList.bindAggregation(..)
相当于XML视图中的items=“{/items}”
。在这种情况下,您是否有任何阻塞/错误?