2011-09-29 66 views
0

在此代碼...煎茶觸摸 - 手風琴佈局

var panel = new Ext.Panel({ 
     fullscreen : true, 
     scroll  : "vertical", 
     layout  : { 
      type : "accordion" 
     }, 
     items: [ 
      { xtype : "panel", title : "One Title", html : "One" }, 
      list, 
      { xtype : "panel", title : "Three Title", html : "Three" }, 
      { xtype : "panel", title : "Four Title", html : "Four" }, 
      { xtype : "panel", title : "Five Title", html : "Five" }, 
      { xtype : "panel", title : "Six Title", html : "Six" } 
     ] 
    }); 

在此,面板標題被硬編碼作爲一個題目,三個冠軍,等等。但我想,以顯示我是什麼結果從數據庫獲得(我創建了模型,我得到的結果顯示)作爲每個面板的標題...如何迭代和顯示..請幫助我..

回答

0

我通過以下

var panel = new Ext.Panel({ 

layout: { 
     type: "accordion" 
    }, 

    initComponent : function() { 

allVisitStore.data.each(function() { 
       alert('inside teration'); 
       jsonObj.push({xtype:"panel", title: this.data['title'], html : this.data['patientId'], style : 'padding-bottom:10px;'}); 
      }); 

} 
}); 
+0

當我加入irems有子項目在其所有未渲染了手風琴面板的動態值..我怎樣才能解決這個問題。? – Sarath

0

你可以收集結果在一個數組然後將此數組添加到面板的項目。可能是這樣的:

var panels = []; 
for (var i=0; i<results.length; i++) { 
var p= '{ xtype : "panel", title : ' + results[i].title + ', html : "' + results[i].html + '" },'; 
panels.push(p); 
} 

var panel = new Ext.Panel({ 
    fullscreen : true, 
    scroll  : "vertical", 
    layout  : { 
     type : "accordion" 
    }, 
    items: panels 
});