gpt4 book ai didi

javascript - 和/或滤波器阵列之间

转载 作者:行者123 更新时间:2023-12-02 23:44:20 25 4
gpt4 key购买 nike

所以我有两个过滤器数组,我想在两个过滤器数组之间执行 AND 操作,而不是仅仅连接并让 UI5 使用和/或运算符选择/分组各自的属性。

我尝试传递两个过滤器数组,并添加和。但它不起作用。

var kFilter = new Filter({
filters: [
dFilters,
bFilters
],
and: true
});

最佳答案

var aFilter = [];
var aOrFilter = [];
var aAndFilter = [];

//Create filter array for OR condition
aOrFilter[
new sap.ui.model.Filter("Property1", sap.ui.model.FilterOperator.EQ, sValue),
new sap.ui.model.Filter("Property2", sap.ui.model.FilterOperator.EQ, sValue)
];

//Create filter array for AND condition
aAndFilter[
new sap.ui.model.Filter("Property3", sap.ui.model.FilterOperator.EQ, sValue),
new sap.ui.model.Filter("Property4", sap.ui.model.FilterOperator.EQ, sValue)
];

//Concatinating both filter arrays with AND condition
aFilter = new sap.ui.model.Filter([
new sap.ui.model.Filter(aOrFilter, false), //Filters get OR codition
new sap.ui.model.Filter(aAndFilter, true) //Filters get AND condition
], true); //Concatinating both with AND condition

结果:

(Property1 EQ "XXX" OR Property2 EQ "XXX") AND (Property3 EQ "XXX" AND Property4 EQ "XXX")

关于javascript - 和/或滤波器阵列之间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55917986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com