【问题标题】:Binding oData read data into sap.m.Table绑定 oData 读取数据到 sap.m.Table
【发布时间】:2015-06-16 14:13:16
【问题描述】:

我正在尝试显示使用 oDataModel.read 获取的一些数据。正如我在网络选项卡中看到的那样,我可以使用我的过滤器值获取数据。但是当我尝试将这些数据显示到表格中时,我无法做到。我已经看到了关于 SCN 的各种讨论,但似乎没有用。

我可以使用 bindAgreggation 获取数据并将其显示在表格中,但问题是我的过滤器无法正常工作。

请查看我用来执行上述操作的以下代码,并建议我如何在表格中显示数据。

oDataModel.read 方法 读取数据:

this.oDataModel.read("/AllocationDocSet", null, ["$filter=Budat ge '" + wkStart + "' and Budat le '" + wkEnd + "'"], true, function(retObj){
      retFunc(retObj.results);
    },
将数据设置到表中:

this.oService.getDocsList(this, calModel.getData().weekStart, calModel.getData().weekEnd, function(retData){
        console.log('setting table model');
        var docsTable = thisRef.byId('ENTRY_LIST_CONTENTS');
        var oTemplate = new sap.m.ColumnListItem(
          {cells: [
                  new sap.m.Text({text : "{Skostl}"}),
                  new sap.m.Text({text : "{Slstar}"}),
                  new sap.m.Text({text : "{Ktext}"}),
                  new sap.m.Text({text : "{Eaufnr}"}),
                  new sap.m.Text({text : "{Epspnr}"}),
                  new sap.m.Text({text : "{Mbgbtr}"}),
                  new sap.m.Text({text : "{Meinh}"}),
                  ]
          });

        var docsModel = new sap.ui.model.json.JSONModel();
        console.log('length: '+retData.length);
        docsModel.setData(retData);
        docsTable.setModel(docsModel);
        docsTable.bindAggregation('items',{path: '/retData',template: oTemplates});

绑定聚合方式:

var wkStartFilter = new sap.ui.model.Filter("Budat", sap.ui.model.FilterOperator.GE, calModel.getData().weekStart);
    var wkEndFilter = new sap.ui.model.Filter("Budat", sap.ui.model.FilterOperator.LE, calModel.getData().weekEnd);
    var buFilters = [];
    buFilters.push(wkStartFilter);
    buFilters.push(wkEndFilter);
    var oTemplate = new sap.m.ColumnListItem(
          {cells: [
                  new sap.m.Text({text : "{Skostl}"}),
                  new sap.m.Text({text : "{Slstar}"}),
                  new sap.m.Text({text : "{Ktext}"}),
                  new sap.m.Text({text : "{Eaufnr}"}),
                  new sap.m.Text({text : "{Epspnr}"}),
                  new sap.m.Text({text : "{Mbgbtr}"}),
                  new sap.m.Text({text : "{Meinh}"}),
                  ]
          });
    var docsTable = thisRef.byId('ENTRY_LIST_CONTENTS');
    docsTable.bindAggregation('items', {path: '/AllocationDocSet',template: oTemplate, filters: buFilters});

我们将不胜感激。

谢谢, 哇

【问题讨论】:

  • @AW:你有什么错误吗?您是否也可以从 OData 调用中发布相同的响应
  • 控制台中没有错误以及所需数据作为响应出现,但未显示在 UI 表格控件中。
  • 任何人都可以在这方面提出一些建议吗?热切地等待回复。

标签: sapui5


【解决方案1】:

指定表格所需的列

var docsTable = new sap.m.Table("idtableorders", {
        growing : true,
        growingThreshold : 10,
        columns : [ 
            new sap.m.Column({}), 
            new sap.m.Column({}), 
            new sap.m.Column({}), 
            new sap.m.Column({}), 
            new sap.m.Column({}),
            new sap.m.Column({}), 
            new sap.m.Column({}) 
            ]
    });

【讨论】:

    猜你喜欢
    • 2016-02-10
    • 1970-01-01
    • 1970-01-01
    • 2013-12-30
    • 2022-12-03
    • 2010-11-19
    • 2018-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多