作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,我有一个搜索字段,后面有这段代码:
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/
我正在使用 sapui5 创建一个表。我想知道我是否可以将升序排序和降序排序的默认图标更改为我自己的图标? 补充问题:有没有一种方法可以在标题中显示我的自定义图标而无需先点击它? 最佳答案 只需在 W
我如何在 SapUI5 中构建一个 XML View 来迭代 JSONModel 中的所有元素? 到目前为止,我有一个 Controller : sap.ui.define([ "sap/ui
我是一名优秀的程序员,十分优秀!