将oData读取数据绑定到sap.m.Table中

时间:2015-06-09 22:50:55

标签: sapui5

我正在尝试显示使用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

1 个答案:

答案 0 :(得分:0)

指定表

所需的列
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({}) 
            ]
    });
相关问题