I have a table that 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]);
},
How can I filter from more columns?
For example if I have the columns A, B, C and D, if I write "hello" in the search bar, I want all results that have in fields A or B or C or D the word "hello".
Please 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 instances of sap.ui.model.Filter. If bAnd is set all filters within the filter will be ANDed else they will be ORed.