与现有聚合绑定的附加过滤器

additional filters on binding with existing aggregation

我有一个带有 table 的值帮助对话框,其行绑定如下:

        // set data
        oValueHelpDialogTable.bindAggregation("rows", {
            path: "/ProductSet",
            filters: aFilters
        });

具有应用于 oData 源的过滤器。

现在我想通过过滤栏设置额外的过滤器:

var bFilters = [];
bFilters.push(new sap.ui.model.Filter(aKeys[0], sap.ui.model.FilterOperator.Contains, oSearchField.getValue()));
var oTableBinding = oValueHelpDialogTable.getBinding();
oTableBinding.filter(bFilters);

但由于某些原因,过滤器未应用。如果我从 bindAggregation 调用中删除 aFilters,其他过滤器将起作用。

作为I.B.N。说,你正在更换你的过滤器,而不是添加一个新的...

我的建议是将过滤器的当前状态保存在控制器的全局变量中或 "view model"

然后在推送新过滤器并再次设置它们之前检索它们。

如果你使用视图模型,它会是这样的

//To save the current filters
this.getView().getModel("myViewModelName").setProperty("/currentFilters", aFilters)

//To retrieve the current filters
var bFilters = this.getView().getModel("myViewModelName").getProperty("/currentFilters")
bFilters.push(new sap.ui.model.Filter(aKeys[0], sap.ui.model.FilterOperator.Contains, oSearchField.getValue()));
var oTableBinding = oValueHelpDialogTable.getBinding();
oTableBinding.filter(bFilters);