SAPUI5: How to filter data with 2 or more values

前端 未结 9 1265
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 20:51

I\'m currently trying some stuff with/in SAPUI5 and I\'ve implemented a very simple search like this:

    var filters = [];
    var query = evt.getParameter(\"qu         


        
9条回答
  •  攒了一身酷
    2021-02-04 21:24

    Have only one filter in the filters array for each of the criteria and it should work,

    var filters = [];
    var sFilter;
    var query = evt.getParameter("query");
    if (query && query.length > 0) {
    
        if(query == "name" )
        {
           sFilter = new sap.ui.model.Filter("name", sap.ui.model.FilterOperator.Contains, query);
        }
        else if(query == "gender")
        {
           sFilter = new sap.ui.model.Filter("gender", sap.ui.model.FilterOperator.Contains, query);
        }
         //and so on...
    
        filters.push(sFilter);
    }
    
    var list = this.getView().byId("list");
    var binding = list.getBinding("items");
    binding.filter(filters);
    

提交回复
热议问题