1

我在 Enyo (WebOS 3.0) 中使用了一个 VirtualRepeater:

{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;    
     }
 }

我想做的是:

  • 如果某事属实,则渲染该行
  • 如果没有,什么都不显示 问题是现在它显示的是空行,而不是什么都没有。它显示包含内容的行和空行,但我不想要任何行。我不能返回 false,否则 VirtualRepeater 将停止渲染行。
4

1 回答 1

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) {
      // 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
}
于 2011-08-17T11:45:19.517 回答