我正在尝试将嵌套数组绑定到表中的列表。
{
"activities": [{
"activityId": "1",
"activityName": "tennis",
"activityHours": [{
"hour": "09:00",
"instructor": "dave"
}, {
"hour": "10:00",
"instructor": "Emma"
}]
}, {
"activityId": "2",
"activityName": "swimming",
"activityHours": [{
"hour": "09:00",
"instructor": "Ella"
}, {
"hour": "10:00",
"instructor": "Ron"
}]
}
]
}
我的view.xml代码:
<Table id="tblFactories" items="{path: 'data>/activities'}">
<items>
<ColumnListItem >
<cells>
<Text text="{data>activityName}"></Text>
<List items="{path: 'data>/activityHours'}" >
<StandardListItem title="{data>hour}" ></StandardListItem>
</List>
</cells>
</ColumnListItem>
</items>
</Table>
但它不起作用。 有谁知道List绑定的正确语法是什么?
谢谢!
答案 0 :(得分:1)
在您的XML代码中,路径不正确。对于List,activityHours是父对象的属性,因此您应该删除&#39; /&#39;。对于List,上下文将如下所示。
<Table id="tblFactories" items="{data>/activities}">
<columns>
<Column>
<Text text="Activity Name" />
</Column>
<Column>
<Text text="Hours" />
</Column>
</columns>
<items>
<ColumnListItem >
<cells>
<Text text="{data>activityName}"></Text>
<List items="{data>activityHours}" >
<StandardListItem title="{data>hour}" ></StandardListItem>
</List>
</cells>
</ColumnListItem>
</items>
</Table>