【问题标题】:sencha touch ajax load listsencha touch ajax 加载列表
【发布时间】:2011-11-16 06:23:00
【问题描述】:

这是我的代码 我想通过 Jsonp 加载一些数据并显示为列表项。

Ext.setup({
    onReady: function(){

        Ext.regModel('Provinces', {
            fields: [{
                name: 'ProvinceID',
                type: 'int'
            }, {
                name: 'ProvinceName',
                type: 'string'
            }]
        });

        var store = new Ext.data.Store({
            autoLoad: true,
            model: 'Provinces',
            fields:['ProvinceName', 'ProvinceID'], 
            proxy: {
                url: 'http://172.19.44.122/BC/Home/GetProvices',
                type: 'jsonp'  
            },
              autoLoad:true
        });

        new Ext.List({
            fullscreen: true,
            itemSelector: '.province',
            tpl: '<tpl for="."><div class="province">{ProvinceName} - {ProvinceID}</div></tpl>',
            store: store
        });
    }
});

JSONP 数据如下所示:

Ext.data.JsonP.callback1([{"ProvinceID":1,"ProvinceName":"shanghai"},"ProvinceID":2,"ProvinceName":"zhejiang"}]);

但结果是页面只显示两个空行。

【问题讨论】:

    标签: ajax list sencha-touch


    【解决方案1】:

    您应该在列表中使用 itemTpl 属性,而不是 tpl,如下所示:

    new Ext.List({
        fullscreen: true,        
        itemTpl: '{ProvinceName} - {ProvinceID}',
        store: store
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-18
      • 1970-01-01
      • 2012-01-15
      • 2023-03-29
      • 1970-01-01
      • 2014-05-25
      • 2014-01-14
      • 1970-01-01
      相关资源
      最近更新 更多