Javascript 与现有聚合绑定时的附加筛选器
我有一个“值帮助”对话框,其中有一个表,其行是这样绑定的:Javascript 与现有聚合绑定时的附加筛选器,javascript,filter,sapui5,aggregation,Javascript,Filter,Sapui5,Aggregation,我有一个“值帮助”对话框,其中有一个表,其行是这样绑定的: // set data oValueHelpDialogTable.bindAggregation("rows", { path: "/ProductSet", filters: aFilters }); 使用应用于oData源的筛选器 现在,我想通过过滤器栏设置其他过滤器: var bFilters = []; bFilters.push
// 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中删除过滤器,则调用其他过滤器工作。正如I.B.N.所说,您正在更换过滤器,而不是添加新的过滤器 我的建议是将过滤器的当前状态保存在控制器的全局变量或“视图模型”中 然后,只需在按下新过滤器并再次设置它们之前检索它们 如果您使用视图模型,它将是这样的
//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);
您正在更换过滤器,而不是添加。