我有一个要绑定到XML视图中的表的odata模型。问题是,我的数据由对象组成,这些对象具有1个属性,即数组。我想在表中显示此数组。
我无法使其正常工作,也许是因为诸如“ ToWorkingDays / Data”之类的表绑定无法正常工作?也许你可以帮我。元数据应该正确。
我的数据:首先是位置,然后是“ ToWorkingDays”数据:
[{
"LocationID": 0,
"Title": "blabla",
"Subtitle": "subtitle",
"RandomNumber": "123"
}]
[{ "LocationID": 0,
"WorkingDaysID": 0,
"Data": [{
"Weekday": "Mon",
"WorkingTimeStart": "08:00",
"WorkingTimeEnd": "18:00",
"PauseTimeStart": "12:00",
"PauseTimeEnd": "13:00"
}, {
"Weekday": "Tue",
"WorkingTimeStart": "08:00",
"WorkingTimeEnd": "18:00",
"PauseTimeStart": "12:00",
"PauseTimeEnd": "13:00"
}] }]
我的XML视图:
<Table items="{ToWorkingDays/Data}">
<columns>
<Column>
<Text text="Weekday"/>
</Column>
<Column>
<Text text="Work Time"/>
</Column>
<Column>
<Text text="Pause Time"/>
</Column>
<Column hAlign="End"/>
</columns>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier title="{Weekday}"/>
<Text text="{parts: [{path: 'WorkingTimeStart'}, {path: 'WorkingTimeEnd'}], formatter: '.getSpanValue'}"/>
<Text visible="{=${PauseTimeStart} !== undefined}"
text="{parts: [{path: 'jsonModel>PauseTimeStart'}, {path: 'PauseTimeEnd'}], formatter: '.getSpanValue'}"/>
<Button icon="sap-icon://edit" press="onEditPress"/>
</cells>
</ColumnListItem>
</items>
</Table>
我的绑定:
this.getView().bindElement({
parameters: {
expand: "ToWorkingDays"
},
path: "/" + sPath
});
我的错误:
列表绑定未绑定到/ ToWorkinDays / Data的列表
通常应该是这样的:items="{modelname>/Customers}
”和<Text text="{modelname>Name"}/>
。
{"Customers":[{
"ID":1,
"Name": "TestCustomer"
}..]}