Sencha touch 外部列表仅显示1个值,而不是所有值

Sencha touch 外部列表仅显示1个值,而不是所有值,sencha-touch,extjs,Sencha Touch,Extjs,im使用AJAX请求以JSON格式从服务器获取值。 但当我尝试在Ext.List中显示此值时,只显示1个值,而不是全部值 Ext.setup({ onReady: function() { Ext.regModel('Contact', { fields: ['firstName', 'lastName'] }); var posts; var count; var name = 'sdf'

im使用AJAX请求以JSON格式从服务器获取值。 但当我尝试在Ext.List中显示此值时,只显示1个值,而不是全部值

Ext.setup({
onReady: function() {

    Ext.regModel('Contact', {
        fields: ['firstName', 'lastName']
    });
            var posts;
            var count;
            var name = 'sdf';
      Ext.Ajax.request({
                    url: 'a.php/pool/listPools',
                    method: 'post',
                    type:'json',
                    success: function(response){
                          posts = Ext.decode(response.responseText);
                          alert(response.responseText);
                          count = posts.count;
                          for (var i = 0; i < count; i++) {
                          name = posts.data[i].name;
                          alert(name);
                          var btnContact = new Ext.TabPanel({
        fullscreen: true,
        items: [ new Ext.List({
                            itemTpl:'',
            title: 'My Tab',
            tpl: '<tpl for="."><div class="contact"><strong>{firstName}</strong> {lastName}</div></tpl>',
            itemSelector: 'div.contact',
            singleSelect: true,
            grouped: true,
            indexBar: false,


            store: new Ext.data.JsonStore({
                model: 'Contact',
                sorters: 'firstName',

                getGroupString: function (record) {
                  return record.get('firstName');
                },
                data:  [
                    {
                                                firstName: name,
                                                lastName: ''
                                            }
                ]
            })
        }), 
                     //{ title: 'Tab 2' } 
                ]   
                    });

                }}               
            });

}
Ext.setup({
onReady:function(){
Ext.regModel('Contact'{
字段:['firstName','lastName']
});
var岗位;
var计数;
变量名称='sdf';
Ext.Ajax.request({
url:'a.php/pool/listPools',
方法:“post”,
类型:'json',
成功:功能(响应){
posts=Ext.decode(response.responseText);
警报(response.responseText);
count=posts.count;
对于(变量i=0;i{firstName}{lastName}”,
项目选择器:“div.contact”,
singleSelect:true,
对,,
indexBar:false,
存储:新Ext.data.JsonStore({
型号:“联系人”,
分拣员:“名字”,
getGroupString:函数(记录){
return record.get('firstName');
},
数据:[
{
名字:名字,
姓氏:“”
}
]
})
}), 
//{标题:'表2'}
]   
});
}}               
});
}
}))


所以我的问题是,如何显示所有检索到的数据?您在for循环中创建的是TabPanel,它为每个数组项创建一个TabPanel,每个TabPanel都有一个绑定到存储的列表,其中存储有一条记录。这些都是相互重叠的,所以你每次只能看到一个

为了快速工作,我将在for循环之外创建TabPanel,并在其中构建数据集:

var dataArray = [];
for (var i = 0; i < count; i++) {
   name = posts.data[i].name;

   dataArray.push({
                   firstName: name,
                   lastName: ''
              });
}
不过,我建议您研究如何让您的商店自己(通过代理)加载这些数据,因为这是最好的方法

斯图尔特

new Ext.data.JsonStore({
            model: 'Contact',
            sorters: 'firstName',

            getGroupString: function (record) {
              return record.get('firstName');
            },
            data:  dataArray
        })