2010-05-19 57 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