嗨,我与它背后的代码searchfield:添加第二过滤器不除去存在的
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);
}
},
和过滤器的按钮,应该添加aditional的过滤器。像这样:
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"));
}
}
的问题是,当我通过过滤器按钮添加一个过滤器,从搜索栏过滤器消失,约于其他方式。我如何更改我的代码,以便我可以添加过滤器而不删除现有的过滤器?
时 输入模拟SearchField
两者都对全球“filtersModel”绑定,都调用_calculateFilters()函数中,我们通过保持所施加多个过滤器控制器级别的过滤器数组。因此,我们首先将过滤器推送到数组,例如this.aFilters.push(oFilter),然后将this.aFilters应用于绑定。寻找更好的解决方案。 –