我有以这种形式的JSON数据:
[
{
"var1": 1,
"var2": "test"
},
{
"var1": 2,
"var2": "something"
}
]
是否可以将其绑定到表或JSON是否需要根元素?如果我将网址更改为/ posts / 1,我可以获得1条记录,但它无法处理多条记录。
var postsModel = new sap.ui.model.json.JSONModel();
postsModel.loadData('https://jsonplaceholder.typicode.com/posts');
var mytab = this.byId('myTable');
mytab.setModel(postsModel);
<Page title="Settings Page">
<content>
<VBox>
<Button press="getInvoices" text="Invoice getter" />
<Table id="myTable" >
<columns>
<Column><header><Label text="userid"/></header></Column>
<Column><header><Label text="id"/></header></Column>
<Column><header><Label text="title"/></header></Column>
<Column><header><Label text="body"/></header></Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{userId}" />
<Text text="{id}" />
<Text text="{title}" />
<Text text="{body}" />
</cells>
</ColumnListItem>
</items>
</Table>
</VBox>
</content>
</Page>
答案 0 :(得分:3)