请在此输入图片描述我想实现sap.ui.model.Filter,它有new sap.ui.model.Filter(sPath, sap.ui.model.FilterOperator.BT, vValue1, vValue2);就像这样,我有8个字段,我只做这样的过滤,但有2个字段我需要实现。和:假的 条件。
https:/sapui5.hana.ondemand.com#apisap.ui.model.Filter。
var product = comboBoxValue.products;
product.forEach(function (allproduct) {
allproduct = allproduct.toUpperCase();
var productValue1 = new sap.ui.model.Filter("PRODUCT", sap.ui.model.FilterOperator.Contains, allproduct);
filters.push(productValue1);
});
// filter the Country values
var country = comboBoxValue.locations;
country.forEach(function (allcountry) {
// allcountry = allcountry.toUpperCase();
var countryValue = new sap.ui.model.Filter("COUNTRY", sap.ui.model.FilterOperator.Contains, allcountry);
// filters.push(countryValue);
});
// filter the Status value
var status = comboBoxValue.status1;
status.forEach(function (allstatus) {
// allcountry = allcountry.toUpperCase();
var statusValue = new sap.ui.model.Filter("SUB_STATUS1", sap.ui.model.FilterOperator.Contains, allstatus);
filters.push(statusValue);
});
// filter the Change type values
var change_type = comboBoxValue.changes;
change_type.forEach(function (allchanges) {
// allcountry = allcountry.toUpperCase();
var changeValue = new sap.ui.model.Filter("CHANGE_TYPE", sap.ui.model.FilterOperator.Contains, allchanges);
filters.push(changeValue);
});
// filter the Submission type values
var sub_type = comboBoxValue.Submissions1;
sub_type.forEach(function (allsub) {
allsub = allsub.toUpperCase();
subValue = new sap.ui.model.Filter("SUB_TYPE", sap.ui.model.FilterOperator.Contains, allsub);
filters.push(subValue);
});
// filter the Manufacturing Stage
var manu_stage = comboBoxValue.stages1;
manu_stage.forEach(function (allstage) {
allstage = allstage.toUpperCase();
var stageValue = new sap.ui.model.Filter("MANUFACTURING_STAGE", sap.ui.model.FilterOperator.Contains, allstage);
filters.push(stageValue);
});
过滤器 我传递给oData服务的数组是像
oModel6.read("/gantt", {
filters: filters,
success: function (oData, oResponse) {
// checking if its region Gantt Chart view
console.log("filtered data will come in oData ");
}
error: function(e){
}
});
现在我已经给了六个过滤器.push(productValue1); 传递后 var productValue1 = new sap.ui.model.Filter("PRODUCT", sap.ui.model.FilterOperator.Contains, allproduct); 使用Sapui5控件filter.to数组过滤器进行过滤。
for (var g = 0; g < comboBoxValue.date_type.length; g++) {
var range = new sap.ui.model.Filter(comboBoxValue.date_type[g], sap.ui.model.FilterOperator.BT, sFrom, sTo);
oFilter.push(range);
}
在这个过程中,我传递了多个comboBoxValue.date_type值和开始日期,结束日期给它。而:真 (你指的是 https:/sapui5.hana.ondemand.com#apisap.ui.model.Filter。 此链接)
但对于这个特定的过滤器,我需要给这个and:false,并将这个and:false给我的过滤器数组,叫做 过滤器
最后陈述:共8个值,其中6个是正常的标准过滤器,并有 而:真 并储存在 过滤器 数组和另外2个字段的日期范围与dat_type要 和:假的并将其存储在 过滤器 阵列
在图像2中,我想要的值是 和:假的 及其他 而:真
我理解你的问题,你总共有8个条件,你希望其中6个用 "or "连接,2个用 "and "连接。这种行为在 文件 与样本#3。
new Filter({
filters: [
...
new Filter({
path: 'Quantity',
operator: FilterOperator.LT,
value1: 20
}),
new Filter({
path: 'Price',
operator: FilterOperator.GT,
value1: 14.0
})
...
],
and: true|false
})
这表明你可以在过滤器中嵌套过滤器,这将是你解决你的问题的方法。在你的情况下,你需要三层嵌套。