Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

search multiple field in one query?

Hi Experts,

I want to know how to filter data more than 2 values..i can able to filter single property data..but i want to search all fields data.

I used below code:

search: function(oEvent)

               var SamTbl = oEvent.getParameter("newValue");

               var filters = new Array();

               var oFilter = new sap.ui.model.Filter("Name", sap.ui.model.FilterOperator.Contains, SamTbl);

//             var oFilter1 = new sap.ui.model.Filter("Age", sap.ui.model.FilterOperator.Contains, SamTbl);       

               filters = (oFilter);

               var listItem =  sap.ui.getCore().byId("oTable");

               var binding = listItem.getBinding("items");

               binding.filter(filters);

can you please say here where i can make change to filter all fields data.

Thanks & Regards,

Palsaran

Former Member replied

Hi Pal

You're very close. Code should be

var contains = sap.ui.model.FilterOperator.Contains;
var filters = new sap.ui.model.Filter([
    new sap.ui.model.Filter("Name", contains, SamTbl),
    new sap.ui.model.Filter("Age", contains, SamTbl)], 
        false); // false for OR      

OR

var contains = sap.ui.model.FilterOperator.Contains;
var columns = ['Name', 'Age', "Column1', ColumnX', ColumnY'];
var filters = new sap.ui.model.Filter(columns.map(function(colName) {
    return new sap.ui.model.Filter(colName, contains, SamTbl); }),
        false);


-D

2 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question