Skip to Content

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 12, 2015 at 04:43 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 12, 2015 at 12:13 PM

    Please anyone address this..

    Thanks,

    Palsaran

    Add comment
    10|10000 characters needed characters exceeded