sencha触摸列表显示

时间:2011-07-13 06:54:55

标签: sencha-touch

我试图从数据库中提取少量记录,并将其显示为其中一个面板(或屏幕)上的列表。但我在屏幕上看不到任何东西。请帮我,我错了。

服务器返回JSON响应

{"success":true,"savedDeals":[
{"dealId":"17","dealName":"$2 Off Any Sandwich","dealText":"Valid with the purchase of any drink on Tuesday through Thursday from 11am to 4pm. Cannot be combined with other offers.","dealCategory":"Restaurant","dealCount":"0","dealRemaining":99999},
{"dealId":"21","dealName":"$10 OFF Kid's Clothing & Gifts","dealText":"Spend $50 and receive $10 off your total purchase","dealCategory":"Baby\/Kids","dealCount":"3","dealRemaining":3}
]}

模型看起来像:

myapp.models.SavedDeals = Ext.regModel("myapp.models.savedDeals", {

     fields: [
        {name : "dealId", type: "int"},
        {name : "dealName", type : "string"},
        {name : "dealText", type : "string"},
        {name : "dealImg", type : "string"},
        {name : "dealCategory", type : "string"},
        {name : "dealCount", type : "int"},
        {name : "dealRemaining", type : "int"},

    ]

 });

商店看起来像

myapp.stores.SSavedDeals = new Ext.data.Store({
model: 'myapp.models.savedDeals',
autoload: true,
id : 'savedDealsStore',
proxy: {
    type: 'ajax',
    url: '/myappfiles/savedDeals.php',
    params: {
        UserID: '62'
    },      
    reader: {
        type: 'json',
        root: 'savedDeals',

    }
},

});

,视图看起来像

        myapp.views.DealraiserSavedDeals = Ext.extend(Ext.Panel,{ 

        fullscreen : true,

        standardSubmit : false,

        dockedItems: [{
            xtype: 'toolbar',
            title: 'Deals List',
            dock: 'top',
            items: [{
                xtype: 'button',
                text: 'Home',
                ui: 'Home',
                handler: function(){                     
                  myapp.views.viewport.setActiveItem(myapp.views.dealraiserHome , 'slide');
                }

            }]
        },
        ],

       items: [{
         xtype: 'list',
         id : 'savedList',
         emptyText   : 'No data available.',
         store: myapp.stores.SSavedDeals,
         itemTpl: '{dealName}'
       }]

       initComponent: function() {
         myapp.stores.SSavedDeals.load();
         myapp.views.DealraiserHome.superclass.initComponent.apply(this, arguments);
       }
 });

请帮忙,我该怎么做才能解决这个问题。

感谢。

1 个答案:

答案 0 :(得分:0)

我认为罪魁祸首就是你正在调用另一个类'超类'的initComponent方法,如果这有意义的话!

initComponent: function() {
    myapp.stores.SSavedDeals.load();
    myapp.views.**DealraiserSavedDeals**.superclass.initComponent.apply(this, arguments);
}

您在initComponent定义之前的'items'数组之后也缺少逗号。

进行这些更改后,列表在本地副本上显示给我 - 唯一的区别是我将数据作为数组而不是PHP文件加载。