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);
},
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?
I think you have 2 options:
Make a new instance of the initially filtered list:
Add
livechange
to yourtextfield
and call a function to filter your list.I solved it using the 'and' condition in filter
WORKING FINE