2013-09-26 50 views
0

我嘗試定義從http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.view.View數據視圖,以http://jsfiddle.net/JtTDH/Extjs4.1 - 定義數據視圖失敗

這裏是我的代碼

Ext.define('Example', { 
    extend: 'Ext.view.View',  
    tpl: new Ext.XTemplate(
    '<tpl for=".">', 
     '<div style="margin-bottom: 10px;" class="thumb-wrap">', 
      '<img src="{src}" />', 
      '<br/><span>{caption}</span>', 
     '</div>', 
    '</tpl>' 
    ), 
    itemSelector: 'div.thumb-wrap', 
    emptyText: 'No images available', 
    initComponent: function() { 
     var store = Ext.create('Ext.data.Store', { 
      id:'imagesStore', 
      fields: [ 
       { name:'src', type:'string' }, 
       { name:'caption', type:'string' } 
      ], 
      data: [ 
       { src:'http://www.sencha.com/img/20110215-feat-drawing.png', caption:'Drawing & Charts' }, 
       { src:'http://www.sencha.com/img/20110215-feat-data.png', caption:'Advanced Data' }, 
       { src:'http://www.sencha.com/img/20110215-feat-html5.png', caption:'Overhauled Theme' }, 
       { src:'http://www.sencha.com/img/20110215-feat-perf.png', caption:'Performance Tuned' } 
      ] 
     }); 

     this.store = store; 
     this.callParent(arguments); 
    } 
}); 

我認爲這是正確的,但無法運作。如何解決這個謝謝。

回答

1

你的代碼很好,但你需要爲它定義一個渲染目標。例如,您可以將renderTo: Ext.getBody()添加到您的定義中,並且它將正常工作。在這裏看到一個工作示例:https://fiddle.sencha.com/#fiddle/md