在sapui5中使用多个参数进行过滤

时间:2017-05-16 14:00:24

标签: sapui5

我正在研究odata fiori app&我想根据两个参数过滤我的列表而不只是一个:" Mpobj" &安培; " Atinn",所以我尝试了这段代码:

    _onObjectMatched: function(oEvent) {
    var sObjectPath = oEvent.getParameter("arguments").infosId;
    var sObjectPath1 = oEvent.getParameter("arguments").objectI;
        var oView = this.getView();
        oView.bindElement(sObjectPath, sObjectPath1);
        var frag = this.getView().byId("tableid1");
        var oFilter = new sap.ui.model.Filter("Mpobj", sap.ui.model.FilterOperator.Contains, sObjectPath);
        var oFilter1 = new sap.ui.model.Filter("Atinn", sap.ui.model.FilterOperator.Contains, sObjectPath1);
        frag.bindElement("Infos" + "/mesureSet").getBinding("items").filter([oFilter], [oFilter1]);
    }, 

但是当我调试时,似乎他正在阅读第一个参数" Mpobj"但是没有认识到第二个" Atinn"。

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

您应该只使用一个数组。请尝试以下

var aFilters=[];
var oFilter = new sap.ui.model.Filter("Mpobj", sap.ui.model.FilterOperator.Contains, sObjectPath);
aFilters.push(oFilter);
var oFilter1 = new sap.ui.model.Filter("Atinn", sap.ui.model.FilterOperator.Contains, sObjectPath1);
aFilters.push(oFilter1);

frag.bindElement("Infos" + "/mesureSet").getBinding("items").filter(aFilters);