与OData

时间:2019-04-23 07:38:45

标签: sapui5

我已将OData链接到表行。在行中未查看数据,但在运行代码时这些行可见。我希望表格显示带有OData的行。请在我的代码中指出问题。 下面是我的控制器代码

onInit: function() {
  var TEST = this.getOwnerComponent().getModel("data");
  var oMeta = TEST.getServiceMetadata();
  var x = oMeta.dataServices.schema[0].entityType[0].property.length;
  var y = oMeta.dataServices.schema[0].entityContainer[0].entitySet[0].name;
  var headerFields = [];
  for (var i = 0; i < x; i++) {
    var property = oMeta.dataServices.schema[0].entityType[0].property[i];
    headerFields.push({
      columnId: property.name
    });
  }
  var oModel = new JSONModel(); // required "sap/ui/model/json/JSONModel"
  oModel.setData({
    columns: headerFields
  });
  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("data>/" + y);
},

0 个答案:

没有答案