Looks like we can't reproduce the issue or there's a problem in the test case provided.
-
Ext JS Premium Member
[4.1B3] Bug with initComponent method of dataview
With dataview example taken from documentation, if initComponent method is added to a dataview, TypeError is thrown:
Code:
Ext.onReady(function() {
Ext.define('Image', {
extend: 'Ext.data.Model',
fields: [
{ name:'src', type:'string' },
{ name:'caption', type:'string' }
]
});
Ext.create('Ext.data.Store', {
id:'imagesStore',
model: 'Image',
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' }
]
});
var imageTpl = new Ext.XTemplate(
'<tpl for=".">',
'<div style="margin-bottom: 10px;" class="thumb-wrap">',
'<img src="{src}" />',
'<br/><span>{caption}</span>',
'</div>',
'</tpl>'
);
Ext.create('Ext.view.View', {
store: Ext.data.StoreManager.lookup('imagesStore'),
tpl: imageTpl,
itemSelector: 'div.thumb-wrap',
emptyText: 'No images available',
renderTo: Ext.getBody(),
// bug: plain initComponent causes throwing a TypeError
initComponent: function() {
this.callParent();
}
});
});
Upon execution above code throws following:
Code:
Uncaught TypeError: Cannot call method 'fill' of undefined
Ext.define.refreshext-all-debug.js:59347
Base.implement.callParentext-all-debug.js:3609
Ext.define.refreshext-all-debug.js:100851
(anonymous function)ext-all-debug.js:59578
(anonymous function)
Damir Murat
-
Never use initComponent when instantiating a class, use it when _defining_ a class.