2013-07-31 19 views
1

我有一個由商店填充的列表項。一旦商店加載,列表似乎不會調整到合適的高度。高度實際上是零。加載商店後,你們有沒有建議讓列表重新計算其高度?由於未定義高度,列表項不會顯示

我的觀點:

  xtype: 'fieldset', 
      cls: 'damage-list-fieldset', 
      margin: '', 
      itemId: 'damageFieldSet', 
      flex: 1, 
      layout: { 
       type: 'fit' 
      }, 
      items: [ 
       { 
        xtype: 'list', 
        action: 'showNotes', 
        cls: 'damage-list', 
        itemCls: 'x-list-item-label', 
        itemId: 'DamageList', 
        disableSelection: true, 
        height: 'auto', 
        emptyText: 'No damage has been reported', 
        itemTpl: [ 
         '<table border="0" width="100%">', 
         ' <tr>', 
         '  <td class="part" width="30%">{part}</td>', 
         '  <td class="note" width="30%">{date}</td>', 
         '  <td class="type" width="30%">{type}</td>', 
         '  <td class="note" width="10%"><div class="count">{noteCount}</div></td>', 
         ' </tr>', 
         '</table>', 
         '' 
        ], 
        store: 'Damage', 
        grouped: true, 
        onItemDisclosure: false 
       } 
      ] 
     }, 

我意識到itemTpl不應該有它的表,但我們忽略了現在。

下面是我目前如何強制它的工作。我從控制器存儲負載回調中推高。

 Ext.getStore('Damage').load({ 
     params: {repairOrderId: this.repairOrderId}, 
     callback: function(records, operation, success) { 
      if(records.length) { 
       report.getComponent('noteInstruction').setHidden(records.length == 0); 

       /* Calculate the height of the damage rows and set it*/ 
       var location = new Array(); 
       var locationCount = 0; 
       for(var i = 0; i < records.length; i++) { 
        if(location.indexOf(records[i].data.location) < 0) { 
         location.push(records[i].data.location); 
         locationCount++; 
        } 
       } 
       var damageRow = 54; 
       var damageHeader = 56; 
       var damageHeight = (records.length * damageRow) + (locationCount * damageHeader); 
       report.getComponent('damageFieldSet').getComponent('DamageList').setHeight(damageHeight); 
       report.getComponent('damageFieldSet').getComponent('DamageList').setScrollable(false); 
      } 
      Ext.Viewport.setMasked(false); 
     }, 
     scope: this 
    }); 

不是很優雅,因爲我只是在設定的高度干擾。

所以問題是,在從商店獲取記錄後,如何強制清單重新繪製其高度?

+0

'fieldset'的容器是什麼?如果您將該容器的佈局設置爲「適合」,那麼該列表應該可以自行工作。 – kevhender

+0

我已經嘗試過,不幸由於某種原因頁面上的按鈕展開以適合整個頁面,並且字段集根本不顯示 – infinityLoop

+0

您是否意味着該列表根本不可見,因爲它的高度?還是你想要實現的東西? – rixo

回答

1

加載過程是異步的,並且來自加載的回調不會影響列表。

  • 可以從list.element.html中讀取高度,並且不需要計算高度,因爲列表已經有一個列表。
  • 加載已自動更新列表。
  • Sencha 2.2.1的列表組件以不同的方式生成。它只產生可見的項目加1的數量和切換listItems中的位置
  • 高度:「自動」將使用Flex是最好更換:1

我建議,你

  • 刪除你的回調
  • 打電話給商店,看看商店裏是否有商品
  • 將listitem高度設置爲固定值(不要試圖設置列表中每行的高度,否則使用dataview並設置在dat上的高度aview upatedata事件)
  • 記住,數據視圖比列表方式較慢,名單上的所有項目都意味着具有相同的高度

最後但並非最不重要的,你可以在列表配置使用:

​​