Extjs4.1-定义数据视图失败
我尝试从到定义一个数据视图 这是我的密码Extjs4.1-定义数据视图失败,extjs,extjs4.1,Extjs,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}" />',
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);
}
});
Ext.define('Example'{
扩展:“Ext.view.view”,
tpl:新Ext.XTemplate(
'',
'',
'',
“
{caption}”,
'',
''
),
itemSelector:'div.thumb-wrap',
emptyText:'没有可用的图像',
initComponent:函数(){
var store=Ext.create('Ext.data.store'{
id:'imagesStore',
字段:[
{名称:'src',类型:'string'},
{名称:'caption',类型:'string'}
],
数据:[
{src:'http://www.sencha.com/img/20110215-feat-drawing.png,标题:'Drawing&Charts'},
{src:'http://www.sencha.com/img/20110215-feat-data.png,标题:'Advanced Data'},
{src:'http://www.sencha.com/img/20110215-feat-html5.png,标题:'彻底改变主题'},
{src:'http://www.sencha.com/img/20110215-feat-perf.png,标题:'Performance Tuned'}
]
});
this.store=商店;
this.callParent(参数);
}
});
我认为那是正确的,但那不起作用。如何修复此问题,谢谢。您的代码很好,但需要为其定义一个渲染目标。例如,您可以将
renderTo:Ext.getBody()
添加到定义中,它将正常工作。请参见此处的工作示例: