2011-06-23 55 views
1

我知道DataView为空的典型原因是因为模型或JSON错误。从我可以告诉,我的是正确的......所以我不知道为什么我的DataView是空白的。Sencha Touch:Ext.DataView不显示商店数据

控制器

rpc.controllers.AboutController = new Ext.Panel({ 
    id: 'rpc-controllers-AboutController', 
    title: 'About', 
    iconCls: 'info', 
    layout: 'card', 
    scroll: 'vertical', 
    items: [rpc.views.About.index], 
    dockedItems: [{ xtype: 'toolbar', 
     title: 'RockPointe Church | Mobile' 
    }], 
    listeners: { 
     activate: function() { 
      if (rpc.stores.AboutStore.getCount() === 0) { 
       rpc.stores.AboutStore.load(); 
      } 
     } 
    } 
}); 

查看

rpc.views.About.index = new Ext.DataView({ 
    id: 'rpc-views-about-index', 
    itemSelector: 'div.about-index', 
    tpl: '<tpl for="."><div class="about-index">{html}</div></tpl>', 
    store: rpc.stores.AboutStore, 
    fullscreen: true, 
    scroll: 'vertical' 
}); 

商店

rpc.stores.AboutStore = new Ext.data.Store({ 
    id: 'rpc-stores-aboutstore', 
    model: 'rpc.models.AboutModel', 
    autoLoad: true, 
    proxy: { 
     type: 'scripttag', 
     url: WebService('About', 'Index'), 
     method: 'GET', 
     reader: { 
      type: 'json', 
      root: 'results' 
     }, 
     afterRequest: function (request, success) { 
      if (success) { 
       console.log("success"); 
      } else { 
       console.log("failed"); 
      } 
      console.log(request); 
     } 
    } 
}); 

rpc.stores.AboutStore.proxy.addListener('exception', function (proxy, response, operation) { 
    console.log(response.status); 
    console.log(response.responseText); 
}); 

型号

rpc.models.AboutModel = Ext.regModel('rpc.models.AboutModel', { 
    fields: ['html'] 
}); 

JSON

myCallBack函数({ “成果”:{ “HTML”: “......内容删除为简洁... ”},“ 成功”:真});

任何人都可以看到我可能做错了吗?

没有控制台/ javascript错误。这些资源显示我实际上是从WebService中取消了JSON。

如果我在AboutController使用console.log(rpc.stores.AboutStore.getCount());activate监听器里,结果总是,我完全不知道为什么

这里的升级应用程序,如果你想看到的要求
http://rpcm.infinitas.ws/(注意,此链接将在某个时间点过期)

回答

1

尝试以数组而不是对象的形式返回您的json值。我认为Ext期待的是一组记录,而不仅仅是一组记录。

例如

“{结果:[{” HTML “: ”你的HTML“}]}”

+0

有没有办法做到这一点没有一个数组?我真的不需要这个项目。 –

+0

这是正确的答案。我将POCO作为'List '连载并发送给Sencha,并按预期工作。 –