Filter by multiple columns
sNow, if I have a table, I can filter from one column:
handleSearch: function(oEvent) {
var sValue = oEvent.getParameter("value");
var oFilter = new sap.ui.model.Filter("RAG_SOC_1", sap.ui.model.FilterOperator.Contains, sValue);
var oBinding = oEvent.getSource().getBinding("items");
oBinding.filter([oFilter]);
},
But can hoc be filtered from more columns?
for example if I have cols: A, B, C, B, if I write "hello" in the search bar, I want all the results that have the word "hello" in fields A or B or C or D
+3
source to share
1 answer
See the following code:
var oFilter1 = new sap.ui.model.Filter("A", sap.ui.model.FilterOperator.Contains, sValue);
var oFilter2 = new sap.ui.model.Filter("B", sap.ui.model.FilterOperator.Contains, sValue);
var oFilter3 = new sap.ui.model.Filter("C", sap.ui.model.FilterOperator.Contains, sValue);
var oFilter4 = new sap.ui.model.Filter("D", sap.ui.model.FilterOperator.Contains, sValue);
var allFilter = new sap.ui.model.Filter([oFilter1,oFilter2,oFilter3,oFilter4]);
var oBinding = oEvent.getSource().getBinding("items");
oBinding.filter(allFilter);
See documentation:
new sap.ui.model.Filter (aFilters, bAnd);
aFilters is an array of other sap.ui.model.Filter instances. If bAnd is set, all filters in the filter will be ANDed else, they will be ORed.
+7
source to share