gpt4 book ai didi

sapui5 - 添加第二个过滤器而不删除现有过滤器

转载 作者:行者123 更新时间:2023-12-02 01:13:56 25 4
gpt4 key购买 nike

您好,我有一个搜索字段,后面有这段代码:

onSearch : function (oEvent) {
if (oEvent.getParameters().refreshButtonPressed) {
// Search field's 'refresh' button has been pressed.
// This is visible if you select any master list item.
// In this case no new search is triggered, we only
// refresh the list binding.
this.onRefresh();
} else {
var andFilter = [];
var sQuery = oEvent.getParameter("query");
if (sQuery && sQuery.length > 0) {
// add filters
var oTableSearchState = [];
oTableSearchState = [new Filter("Supplier", FilterOperator.Contains, sQuery), new Filter("BusArea", FilterOperator.Contains, sQuery), new Filter("CostCenter", FilterOperator.Contains, sQuery),
new Filter("FuncArea", FilterOperator.Contains, sQuery)];
andFilter.push(new Filter(oTableSearchState, false));
}
this._applySearch(andFilter);
}
},

还有一个应该添加额外过滤器的过滤器按钮。像这样:

onSetFilter : function(oEvent) {
var andFilter = [];
andFilter.push(new Filter("BusArea", FilterOperator.EQ, "5000"));
this._applySearch(andFilter);
},

当然,“BusArea”部分应该取决于选择的过滤器。它可能超过 1 个过滤器。 _applySearch 函数如下所示:

_applySearch: function(andFilter) {
var oViewModel = this.getModel("worklistView");
this._oTable.getBinding("items").filter(andFilter, true);
// changes the noDataText of the list in case there are no filter results
if (andFilter.length !== 0) {
oViewModel.setProperty("/tableNoDataText",
this.getResourceBundle().getText("worklistNoDataWithSearchText"));
}
}

问题是,当我通过过滤器按钮添加过滤器时,搜索栏中的过滤器消失了,反之亦然。我如何更改我的代码,以便我可以在不删除现有过滤器的情况下添加过滤器?

最佳答案

一种解决方案是从绑定(bind)信息中获取过滤器,并使用 将新过滤器一起推回。

this._oTable.getBindingInfo("items").filters.aFilters;

关于sapui5 - 添加第二个过滤器而不删除现有过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43606435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com