我无法将OData连接到普通表以动态创建行。我的以下代码用于正常创建不带OData的行。
var aColumnData = [
{
columnId: "col1"
},
{
columnId: "col2"
},
// ...
];
var aData = [
{
col1: "Row 1 col 1",
col2: "Row 1 col 2",
// ...
},
{
col1: "Row 2 col 1",
col2: "Row 2 col 2",
// ...
},
// ...
];
var oModel = new JSONModel(); // required "sap/ui/model/json/JSONModel"
oModel.setData({
columns: aColumnData,
rows: aData
});
var oTable = this.getView().byId("usertable");
oTable.setModel(oModel);
oTable.bindColumns("/columns", function(index, context) {
var sColumnId = context.getObject().columnId;
return new Column({ // required "sap/ui/table/Column"
label: sColumnId,
template: sColumnId
});
});
oTable.bindRows("/rows");
如何通过读取OData服务的元数据获得相同的结果?