Monaca Onsen UI Discord Chat Github Repo

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 :-)


  • administrators

    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 of obj change (for example when you filter items or add items to the array) you should call the refresh method of ons-lazy-repeat.



  • okay, i get it ;) thats something i can implement… :-D