我正在尝试过滤多个组合框。 如果执行以下逻辑,我的代码似乎可以正常工作:(CreatedBy1)&&(TaskStatus1) Image
查看:
<fb:FilterBar id="filterBar" useToolbar="false" search="onPressGo">
<fb:filterGroupItems>
<fb:FilterGroupItem visibleInFilterBar="true" groupName="G1" groupTitle="Group1" name="A8" label="Region">
<fb:control>
<MultiComboBox
id = "Region"
width = "260px"
items="{
path: '/VH_RegionSet',
sorter: { path: 'Text' }
}">
<core:Item key="{Code}" text="{Text}" />
</MultiComboBox>
</fb:control>
</fb:FilterGroupItem>
<fb:FilterGroupItem groupName="G1" groupTitle="Group1" name="A7" visibleInFilterBar="true" label="Road Master Area">
<fb:control>
<MultiComboBox
id = "RoadMasterAreaId"
width = "260px"
items="{
path: '/VH_RoadMasterAreaSet',
sorter: { path: 'Text' }
}">
<core:Item key="{Code}" text="{Text}" />
</MultiComboBox>
</fb:control>
</fb:FilterGroupItem>
<fb:FilterGroupItem groupName="G1" groupTitle="Group1" name="A6" visibleInFilterBar="true" label="Sub-Division/Yard Indicator">
<fb:control>
<MultiComboBox
id = "SubdivYardIndicator"
width = "260px"
items="{
path: '/VH_SubdivYardIndicatorSet',
sorter: { path: 'Text' }
}">
<core:Item key="{Code}" text="{Text}" />
</MultiComboBox>
</fb:control>
</fb:FilterGroupItem>
<fb:FilterGroupItem groupName="G1" groupTitle="Group1" name="A5" visibleInFilterBar="true" label="Track Type">
<fb:control>
<MultiComboBox
id = "TrackType"
width = "260px"
items="{
path: '/VH_TrackTypeSet',
sorter: { path: 'Text' }
}">
<core:Item key="{Code}" text="{Text}" />
</MultiComboBox>
</fb:control>
</fb:FilterGroupItem>
<fb:FilterGroupItem groupName="G1" groupTitle="Group1" name="A4" visibleInFilterBar="true" label="Asset Type">
<fb:control>
<MultiComboBox
id = "AssetType"
width = "260px"
items="{
path: '/VH_AssetTypeSet',
sorter: { path: 'Text' }
}">
<core:Item key="{Code}" text="{Text}" />
</MultiComboBox>
</fb:control>
</fb:FilterGroupItem>
<fb:FilterGroupItem groupName="G1" groupTitle="Group1" name="A3" visibleInFilterBar="true" label="Created By">
<fb:control>
<MultiComboBox
id = "CreatedBy"
width = "260px"
items="{
path: '/VH_CreatedBySet',
sorter: { path: 'Text' }
}">
<core:Item key="{Code}" text="{Text}" />
</MultiComboBox>
</fb:control>
</fb:FilterGroupItem>
<fb:FilterGroupItem groupName="G1" groupTitle="Group1" name="A2" visibleInFilterBar="true" label="Characteristic">
<fb:control>
<MultiComboBox
id = "CharacteristicId"
width = "260px"
items="{
path: '/VH_CharacteristicSet',
sorter: { path: 'Text' }
}">
<core:Item key="{Code}" text="{Text}" />
</MultiComboBox>
</fb:control>
</fb:FilterGroupItem>
<fb:FilterGroupItem groupName="G1" groupTitle="Group1" name="A1" visibleInFilterBar="true" label="Task Status">
<fb:control>
<MultiComboBox
id = "TaskStatus"
width = "260px"
items="{
path: '/VH_TaskStatusSet',
sorter: { path: 'Text' }
}">
<core:Item key="{Code}" text="{Text}" />
</MultiComboBox>
</fb:control>
</fb:FilterGroupItem>
控制器:
onPressGo: function (oEvent) {
var oTaskFilter = [];
var afinalFilter = [];
var aTaskFilter = [];
var aQuery = ["Region","RoadMasterAreaId","SubdivYardIndicator","TrackType","AssetType","CreatedBy","CharacteristicId","TaskStatus"];
if (oEvent.getParameters().refreshButtonPressed) {
this.onRefresh();
}
else {
for(var i= 0; i< aQuery.length ; i++){
var sQuery = this.byId(aQuery[i]).getSelectedKeys();
if(sQuery){
for(var j=0 ; j< sQuery.length ; j++){
oTaskFilter.push(new Filter({
path : aQuery[i],
operator : FilterOperator.EQ,
value1: sQuery
}));
aTaskFilter=aTaskFilter.concat(oTaskFilter);
}
}
afinalFilter=afinalFilter.concat(aTaskFilter);
}
this._applySearch(afinalFilter);
}
},
但是我正在尝试做:(CreatedBy1)&&(TaskStatus1&TaskStatus2)屏幕将出现“找不到匹配项”。 不知何故,如果我在同一ComboBox中选择了多个值,那将不起作用。 Image
答案 0 :(得分:0)
尝试使用bAnd = false定义OTaskFilter = new sap.ui.model.Filter(aFilters, bAnd);
,然后将您的“过滤器”放入该过滤器的过滤器数组中,然后重试。
这将确保您收集的所有过滤器都与OR连接。
答案 1 :(得分:0)
我已经这样做了,当user1与taskStatus1&taskStatus2一起使用时,它会进行过滤。但是,当我仅选择user1和user2时,它不会过滤。 Image
onPressGo: function (oEvent) {
var oTaskFilter = [];
var afinalFilter = [];
var aTaskFilter = [];
var aQuery = ["Region","RoadMasterAreaId","SubdivYardIndicator","TrackType","AssetType","CreatedBy","CharacteristicId","TaskStatus"];
if (oEvent.getParameters().refreshButtonPressed) {
this.onRefresh();
}
else {
for(var i= 0; i< aQuery.length ; i++){
var sQuery = this.byId(aQuery[i]).getSelectedKeys();
if(sQuery){
for(var j=0 ; j< sQuery.length ; j++){
oTaskFilter.push(new Filter({path : aQuery[i],
operator : FilterOperator.EQ,
value1: sQuery
})
);
aTaskFilter.push(new Filter (oTaskFilter,false));
}
}
afinalFilter.push(new Filter(aTaskFilter,true));
}
this._applySearch(afinalFilter);
}
},