i have list contains objectlistitems content provided odata service. 1 of contents title , property has value follows:
title="{ path: 'title', formatter: 'app.schedule.util.formatter.titletext'}"
as can see there formatter in title. odata bring value "available" or "disabled" , formatter transform on text specific language of user.
i'm implementing search capability on list , works fine, problem searchs on "available" , "disabled" values, , not in formatted texts expected not values recognized user.
the filter code is:
handlesearch : function (evt) { // create model filter var filters = []; var query = evt.getparameter("query"); if (query && query.length > 0) { filters.push(new sap.ui.model.filter("booked", sap.ui.model.filteroperator.contains, query)); filters.push(new sap.ui.model.filter("weekday", sap.ui.model.filteroperator.contains, query)); filters.push(new sap.ui.model.filter("title", sap.ui.model.filteroperator.contains, query)); filters = new sap.ui.model.filter(filters, false); } // update list binding var list = this.getview().byid("list"); var binding = list.getbinding("items"); binding.filter(filters); },
any idea on how consider formatter on filter , not raw data?
solution considering doing client side search: assumption: if have grouping in list..
handlesearch : function (evt) { sfilterpattern = evt.getparameter("query"); sfilterpattern = sfilterpattern.tolowercase(); var alistitems = this.getview().byid("list").getitems(); var bvisibility; var ogroupitem = null; var icountingroup = 0; (var = 0; < alistitems.length; i++) { if (alistitems[i] instanceof sap.m.groupheaderlistitem) { if (ogroupitem) { if (icountingroup == 0) { ogroupitem.setvisible(false); } else { ogroupitem.setvisible(true); ogroupitem.setcount(icountingroup); } } ogroupitem = alistitems[i]; icountingroup = 0; } else { bvisibility = this.applysearchpatterntolistitem(alistitems[i], sfilterpattern); alistitems[i].setvisible(bvisibility); if (bvisibility) { icountingroup++; } } } if (ogroupitem) { if (icountingroup == 0) { ogroupitem.setvisible(false); } else { ogroupitem.setvisible(true); ogroupitem.setcount(icountingroup); } } } applysearchpatterntolistitem:function(oitem, sfilterpattern) { if (sfilterpattern == "") { return true; } //uncomment search in omodel data /*var oiteshellata = oitem.getbindingcontext(this.smodelname).getproperty(); (var skey in oiteshellata) { var svalue = oiteshellata[skey]; // if (svalue instanceof date) { // //just filter take each number string // svalue = svalue.getdate() + "." + // svalue.getmonth() + "." + svalue.getfullyear(); // } if (typeof svalue == "string") { if (svalue.tolowercase().indexof(sfilterpattern) != -1) { return true; } } }*/ // if nothing found in unformatted data, check ui elements if ((oitem.getintro() && oitem.getintro().tolowercase().indexof(sfilterpattern) != -1) || (oitem.gettitle() && oitem.gettitle().tolowercase().indexof(sfilterpattern) != -1) || (oitem.getnumber() && oitem.getnumber().tolowercase().indexof(sfilterpattern) != -1) || (oitem.getnumberunit() && oitem.getnumberunit().tolowercase().indexof(sfilterpattern) != -1) || (oitem.getfirststatus() && oitem.getfirststatus().gettext().tolowercase().indexof(sfilterpattern) != -1) || (oitem.getsecondstatus() && oitem.getsecondstatus().gettext().tolowercase().indexof(sfilterpattern) != -1)) { return true; } // last source attribute array var aattributes = oitem.getattributes(); (var j = 0; j < aattributes.length; j++) { if (aattributes[j].gettext().tolowercase().indexof(sfilterpattern) != -1) { return true; } } return false; }
Comments
Post a Comment