2011-09-29 100 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 
});