Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
ons-lazy-repeat filtering
-
Hi,
i have problems understanding the filtering of Onsen UI Lazy repeat Lists. I do create a List with pure javascript and ons-lazy-repeat:
// get json object from fileData (is retrieved before) obj = JSON.parse(fileData); //inject data into lazy repeat list list.delegate = { createItemContent: function (i) { // Return a DOM element here. return ons.createElement('<ons-list-item modifier="chevron"><div class="left"><img class="list-item__thumbnail" src="blubb"></div><div class="center">' + obj[i]["headName"] + '</div></ons-icon></div></ons-list-item>'); }, countItems: function () { // Return the number of items here. return obj.length; } };
How do i filter the list by say the first three chars of
obji]["headName"]
… i dont get it…
thanks in advance :-)
-
The ons-lazy-repeat doesn’t actually do the filtering. Instead you should filter the array of items you are creating the list from (
obj
in your case). When the contents ofobj
change (for example when you filter items or add items to the array) you should call therefresh
method of ons-lazy-repeat.
-
okay, i get it ;) thats something i can implement… :-D