0 votes
1 view
in SAP by (7k points)

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");

But hoc can I filter from more cols?

for example if I have cols: A, B, C, B, 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"

1 Answer

0 votes
by (14.5k points)

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");


Use the above mentioned line of code to resolve your issue. 

From the 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.

Related questions

0 votes
0 answers
0 votes
1 answer
0 votes
1 answer
asked Jul 29, 2019 in SAP by Karan Singh (7k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !