2010-05-19 61 views
0

我正在尝试使DataView工作(在Ext JS 2.3上)。Ext.data.JsonStore + Ext.DataView =未加载记录

这里是jsonStore,它似乎在工作(它调用服务器并获得有效的响应)。

Ext.onReady(function(){ 

     var prefStore = new Ext.data.JsonStore({ 
      autoLoad: true, //autoload the data 
      url: 'getHighestUserPreferences', 
      baseParams:{ 
       userId: 'andreab', 
       max: '50' 
      }, 
      root: 'preferences', 
      fields: [ 
       {name:'prefId', type: 'int'}, 
       {name:'absInteractionScore', type:'float'} 
      ] 
     }); 

然后xtemplate:

 var tpl = new Ext.XTemplate(
       '<tpl for=".">', 
        '<div class="thumb-wrap" id="{name}">', 
        '<div class="thumb"><img src="{url}" title="{name}"></div>', 
        '<span class="x-editable">{shortName}</span></div>', 
       '</tpl>', 
       '<div class="x-clear"></div>' 
     ); 

面板:

 var panel = new Ext.Panel({ 
      id:'geoPreferencesView', 
      frame:true, 
      width:600, 
      autoHeight:true, 
      collapsible:false, 
      layout:'fit', 
      title:'Geo Preferences', 

而且数据视图

  items: new Ext.DataView({ 
       store: prefStore, 
       tpl: tpl, 
       autoHeight:true, 
       multiSelect: true, 
       overClass:'x-view-over', 
       itemSelector:'div.thumb-wrap', 
       emptyText: 'No images to display' 
      }) 
     }); 
     panel.render('extOutput'); 
    }); 

我得到的页面是一个蓝色的边框与标题,但没有任何内容。 我该如何调试,看看它为什么不工作?

干杯, Mulone

回答

3

你的店不匹配模板,复制这个刚从例子没有你:P

模板中的项目(名称)等是指领域在商店,你的情况只是prefId和absInteractionScore。

这个示例模板期望的是一个图像的名称和url,然后它构造一些图像和一个for。

+0

干杯!有效。 – Mulone 2010-05-21 10:15:49