本文介绍了如何过滤 sap.m.list 中过滤的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一个 sap.m.list,它已经根据一个属性进行了过滤.现在我再次需要为该列表应用过滤器以实现实时搜索.

I alredy have an sap.m.list which is already filtered based on one property.Now I again need to apply filter for that list to implement live search.

filterList:function(evt){
        debugger;
        var filters = [];
         var oFilter="";
        var query = evt.oSource.mProperties.value;
        if (query && query.length > 0) {
            var filter = new sap.ui.model.Filter("CLTYPE", sap.ui.model.FilterOperator.Contains, query);
            filters.push(filter);

            var filter1 = new sap.ui.model.Filter("CLCAT", sap.ui.model.FilterOperator.Contains, query);
            filters.push(filter1);
            var filter2 = new sap.ui.model.Filter("CLNUM", sap.ui.model.FilterOperator.Contains, query);
            filters.push(filter2);

            oFilter = new sap.ui.model.Filter( filters, false );
        }


        // update list binding
        var list = sap.ui.getCore().byId("List");
        var binding = list.getBinding("items");
        binding.filter(oFilter);
    },

这里我的列表已经过滤.这里 list.getBinding('items') 会给我所有的项目而不是过滤的项目.我为我的 sap.m.list 应用了过滤器,如下

here my list is already filtered.here list.getBinding('items') will give me all the items not the filtered Items.I applied filter for my sap.m.list as follows

     obj[filterParam] = context;

    var contextClauses=_.where(clauses,obj);
    sap.ui.getCore().getModel('ClauseModel').setProperty("/DATA/CURRENTCLAUSES",contextClauses);

// update list binding
var list = sap.ui.getCore().byId("List");
var binding = list.getBinding("items");
binding.filter(oFilter);

如何实施?有什么建议吗?

how to implement that??any suggestions?

推荐答案

我用过滤器中的'and'条件解决了

I solved it using the 'and' condition in filter

 var mainFilter=new sap.ui.model.Filter(parameter,sap.ui.model.FilterOperator.Contains,context);
        var query =evt.getParameter("newValue");
        if (query && query.length > 0)var filter1= new sap.ui.model.Filter("CLNAME",sap.ui.model.FilterOperator.Contains,query);
            filtersArr1.push(filter1);
            filtersArr1.push(mainFilter);
          var filter2 = new sap.ui.model.Filter("CLNUM",sap.ui.model.FilterOperator.Contains, query);
            filtersArr2.push(filter2);
            filtersArr2.push(mainFilter);oFilter1 = new sap.ui.model.Filter(filtersArr1,true);oFilter2 = new sap.ui.model.Filter(filtersArr2,true);filterGroup.push(oFilter1,oFilter2);oFilter4 = new sap.ui.model.Filter(filterGroup,false);
            binding.filter(oFilter4);

工作正常

这篇关于如何过滤 sap.m.list 中过滤的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 04:11