sencha touch - 手风琴布局

时间:2011-09-29 11:36:04

标签: sencha-touch accordion

在此代码中......

    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"   }
        ]
    });

在这里,面板标题被硬编码为一个标题,三个标题等。但我想显示我从数据库得到的结果(我创建了模型,我得到了显示的结果)as每个小组的标题...如何迭代和显示..请帮助我..

2 个答案:

答案 0 :(得分: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
});

答案 1 :(得分: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;'});
            });

}
});