如何使用不同的运算符连接两个 sap.ui.model.filter



>Ui5 文档提供了一个示例,将过滤器列表与 AND 或 OR 组合在一起:

new sap.ui.model.Filter({
   filters: [...],
   and: true|false
})

我有两个与OR连接的滤波器数组,如何将这两个数组与ALL连接?喜欢这个:

产品?$skip=0&$top=20&$filter=(substringof('One way',ID( 或 substringof('单向',类型(子字符串('A',Name(或方向eq "A">

下面是我的代码:

oTableSearchState1 = [new Filter(filterArray1, false)] //OR
oTableSearchState2 = [new Filter(filterArray2, false)] //OR
oTable.getBinding("items").filter(oTableSearchState1, "Application");

(我已经尝试了new Filter(filterArray1.concat(filterArray2), false);oTable.getBinding("items").filter(oTableSearchState1, "Application").filter(oTableSearchState2, "Application"),显然它们不起作用。

对于需要执行此类复杂操作的情况,可以使用嵌套筛选。您可以使用过滤器中的筛选器来执行此类操作。

以下是根据您的问题的示例过滤器:

var oFilter = new Filter({
            filters: [
                new Filter({
                    filters:[
                        new Filter("ID", FilterOperator.Contains, "One way"),
                        new Filter("Type", FilterOperator.Contains, "One way")
                    ],
                    and : false
                }),
                new Filter({
                    filters:[
                        new Filter("Name", FilterOperator.Contains, 'A'),
                        new Filter("Direction", FilterOperator.EQ, "A")
                    ],
                    and : false
                })
            ],
            and: true
        });

最新更新