如何在odata模型读取操作中应用过滤器?

时间:2016-08-25 05:35:29

标签: javascript odata sapui5

我正在尝试在odata模型读取操作中添加过滤器。这是他们提到的将link作为参数传递的{{3}}。

var a = new sap.ui.model.Filter({  
                 path: "Source",  
                 operator: sap.ui.model.FilterOperator.EQ,  
                 value1: "Delhi, India"
          }); 

var b =new sap.ui.model.Filter({  
                 path: "Destination",  
                 operator: sap.ui.model.FilterOperator.EQ,  
                 value1: "Kolkata, West Bengal, India"
          });  

var f = new Array();f.push(a);f.push(b);

this.getView().getModel().read("/Lanes", { filters : f},{
        method: "GET",
        success: function(data) {

            console.log("Carrier model setting up..");
            console.log(data);
}});

1 个答案:

答案 0 :(得分:2)

              var mParameters = {
                filters : f, // your Filter Array
                success : function (oData, oResponse) {

                },
                error: function (oError) {

                }
              };

            this.getView().getModel().read("/Lanes",mParameters);