PDA

View Full Version : Problem extends Ext.Toolbar



int08h
19 Apr 2008, 11:35 PM
I have checked the forum but do not find any related threads to deal with my problem.

In my case, I exntends Ext.Toolbar like

MyToolbar = Ext.extend(Ext.Toolbar, {
width: 800,
height: 300,
renderTo: document.body,
items: [{
xtype: 'textfield',
fieldLabel: 'text1'
}],

initComponent : function(){
MyToolbar.superclass.initComponent.call(this);
this.addText('a');
}
});

However, when I instantiating MyToolbar using var tb = new MyToolbar(), it raises an error saying: "'this.tr' is null or not an object", code breaks at this line:
this.addText('a');

I dont know how it happens, so any help would be appreciated, thanks.

Animal
20 Apr 2008, 12:28 AM
YOu cannot add stuff until its rendered. initComponent is called before the renderTo is examined and acted upon. You will have to put your 'a' text item in the items config.

int08h
20 Apr 2008, 1:54 AM
Thanks, I didn't use "item" options config because I didn't see it in API document.

Animal
20 Apr 2008, 3:34 AM
Erm, you are using it!