SAPUI5过滤条搜索具有多个组合框的过滤器组项目

问题描述 投票:0回答:1

qazxsw poii试图使用过滤条过滤,但价值没有出来。没有错误,只是价值没有出来

aFilters array

sapui5
1个回答
0
投票

在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);
© www.soinside.com 2019 - 2024. All rights reserved.