2016-09-15 78 views
0

我有一个OData的模型,我需要进行批量读取请求 的模型ctreated如下UI5 OData服务与一批GET与过滤器

this.oModel = new sap.ui.model.odata.ODataModel(sURI,{ 
       json  : true, 
       user  : "<username>", 
       password : "<password>", 
       useBatch : true 
     }); 

过滤器和批次要求如下创建

var allfilters = [new sap.ui.model.Filter({ 
       path:'filter1', 
       operator : sap.ui.model.FilterOperator.EQ, 
       value1 : this.filter1value 
      }), 
      new sap.ui.model.Filter({ 
       path:'DateField', 
       operator : sap.ui.model.FilterOperator.EQ, 
       value1 : 'SCHED' 
      }), 
      new sap.ui.model.Filter({ 
       path:'StartDate', 
       operator : sap.ui.model.FilterOperator.EQ, 
       value1 : oDateFormat.format(this.startDate.toDate()) 
      }), 
      new sap.ui.model.Filter({ 
       path:'EndDate', 
       operator : sap.ui.model.FilterOperator.EQ, 
       value1 : oDateFormat.format(this.endDate.toDate()) 
      })]; 

     var batchrequest = this.oModel.createBatchOperation('/ReadEntitySet','GET',{ 
      filters : allfilters 
     }); 
     this.oModel.addBatchReadOperations([batchrequest]); 
     this.oModel.submitBatch(this._gotData.bind(this),function(err){ 
      console.log(err); 
     }); 

当我们调试ABAP代码时,我们没有得到过滤器。

回答

2

过滤器不是createBatchOperation的oData参数的有效属性。您可以通过将$ filter直接附加到您的路径来实现此目的,也可以使用v2 ODataModel,示例如下:

this.oModel = new sap.ui.model.odata.v2.ODataModel(sURI,{ 
      json  : true, 
      user  : "<username>", 
      password : "<password>", 
      useBatch : true 
}); 

this.oModel.setDeferredGroups(["myDeferredGroup"]); 

this.oModel.read("/ReadEntitySet",{ 
    groupId: "myDeferredGroup", 
    filters: allFilters, 
    success: this._gotData.bind(this), 
    error : function(err){ 
     console.log(err); 
    } 
}); 

this.oModel.submitChanges({ 
    groupId: "myDeferredGroup", 
    success: function(oData){ 

    }, 
    error : function(err){ 
    } 
});