在SAP提供的onSearch: function(oEvent) {
//get the filter bar from the event
var oFilterBar = oEvent.getSource();
//get the filter items from the filter bar
var aFilterGroupItems = oFilterBar.getFilterGroupItems();
//map the array of FilterItems to a new array of sap.ui.model.Filter objects
var aFilters = aFilterGroupItems.map(function(oFilterGroupItem) {
//get the filter item name (which is now the same as the filter property name)
var sFilterName = oFilterGroupItem.getGroupName();
//use the filter bar to get the control for the filter
var oControl = oFilterBar.determineControlByFilterItem(oFilterGroupItem);
//use the control to get the selected value (selected key)
var sSelectedValue = oControl.getSelectedKeys();
var oFilter = new sap.ui.model.Filter(sFilterName, "EQ", sSelectedValue);
return oFilter;
});
this.getView().byId("table").getBinding("items").filter(aFilters);
}
文档中,提到如果要组合多个过滤器(AND或OR),则应创建一个新的Filter对象,其属性为Filterwhich,其中包含您要应用的已定义过滤器对象的数组。
根据该信息,您可以尝试在onSearch函数中添加以下代码(在关闭filters
之后):
.map()
并替换
var oFinalFilter = sap.ui.model.Filter({
filters: aFilters, //aFilters = array of created Filter-objects
and: true //true|false depending on requirements
});
通过
this.getView().byId("table").getBinding("items").filter(aFilters);