0

我尝试从http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.view.Viewhttp://jsfiddle.net/JtTDH/定义一个数据视图

这是我的代码

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);  
    }
});

我认为这是正确的,但这是行不通的。怎么解决谢谢。

4

1 回答 1

1

您的代码很好,但您需要为它定义一个渲染目标。例如,您可以添加renderTo: Ext.getBody()到您的定义中,它会正常工作。在此处查看一个工作示例:https ://fiddle.sencha.com/#fiddle/md

于 2013-09-26T09:38:58.543 回答