Search code examples
webospalmenyo

How can I hide rows in a VirtualRepeater?


I'm using one VirtualRepeater in Enyo (WebOS 3.0):

{kind: enyo.VirtualRepeater, name: "eventList", onSetupRow: "setupRowWithEvent", onclick: "doListTap", components: [
   {kind: enyo.Item, name:"eventItem", layoutKind: enyo.HFlexLayout, tapHighlight: true, components: [
       /* components of every row: inside a Enyo.Item */       
   ]} 
]}                                 
/* more code */
setupRowWithEvent: function(inSender, inIndex) {
     if (somethingIsTrue) {

         return true;    
     }
 }

What I want to do is:

  • if something is true, render the row
  • if not, show nothing The problem is that now it's showing empty rows, instead of nothing. It shows rows with content and empty rows, but I want no rows. I can't return false, or the VirtualRepeater will stop rendering rows.

Solution

  • The solution I've found is simple:

    {kind: enyo.VirtualRepeater, name: "eventList", onSetupRow: "setupRowWithEvent", onclick: "doListTap", components: [
        {kind: enyo.Item, name:"eventItem", layoutKind: enyo.HFlexLayout, tapHighlight: true, components: [
            /* components of every row: inside a Enyo.Item */       
        ]} 
    ]}                                 
    /* more code */
    setupRowWithEvent: function(inSender, inIndex) {
      if (somethingIsTrue) {
          // code to update every row 
    
      } else {  // we don't want this row to show
          this.$.eventItem.setShowing(false);
      } 
     return true; // if you don't return true, the virtual Repeater stops fetching rows
    }