sapui5 - SAPUI5过滤器栏搜索过滤器组项目与多组合框
问题描述
aFilters 数组我尝试使用过滤器栏进行过滤,但值没有出来。没有错误,只是值不出来
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);
}
解决方案
在SAP 提供的过滤器文档中,提到如果您想组合多个过滤器(AND 或 OR),您应该创建一个新的过滤器对象,其属性filters
包含您希望应用的已定义过滤器对象的数组。
根据该信息,您可以尝试在 onSearch 函数中添加以下代码(关闭 后.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);
经过
this.getView().byId("table").getBinding("items").filter(oFinalFilter);
推荐阅读
- python - 在python中对附加行进行编号或计数
- python - Python - 覆盖继承的单例类方法
- wordpress - 如何在 WooCommerce 上基于 2 个属性显示产品?
- django - 如何在没有 Django 表单的 Django 模板中使用 CKEDITOR 并保存数据
- reactjs - React Router Link 无法克隆功能
- c - scanf("%f",&aa) VS scanf("%f",&aa) 在 while 循环中
- google-cloud-firestore - Dialogflow - Firestore - Webhook 调用失败。错误:UNAVAILABLE,状态:URL_UNREACHABLE,原因:UNREACHABLE_5xx,HTTP 状态代码:500
- python-3.x - 我如何在 python3 上使用 sys.stdout.flush()
- windows - 请如何解决在窗口上安装火花的这些错误。请任何人帮助找到这些错误的解决方案。我无法启动项目
- javascript - 如何按 id 和 name 对对象数组进行排序?