PDA

View Full Version : Extending Ext.Editor...



tomtom-
14 Nov 2009, 4:38 AM
Hi everybody,

I'm trying to extend Ext.Editor class like this :



ComponentEditor = Ext.extend(Ext.Editor, {

initComponent: function(){
Ext.apply(this, {
field: {xtype: 'textfield'},
updateEl: true,
cancelOnEsc: true,
completeOnEnter: true
});

this.on('complete', function(){
Ext.get(this.formId).setWidth(Ext.get(this.parentId).getWidth());
Ext.get(this.formId).setHeight(Ext.get(this.parentId).getHeight());
});

ComponentEditor.superclass.initComponent.apply(this, arguments);
},

onRender: function(){

ComponentEditor.superclass.onRender.apply(this, arguments);

},

startEdit: function(component, parentId, formId){
this.parentId = parentId;
this.formId = formId;
ComponentEditor.superclass.startEdit.apply(this, arguments);
},

});


To follow, if I instantiate the object like this :

var editor = new ComponentEditor({field:{xtype:'textfield'}});
it works fine. But if I instantiate the object like this :

var editor = new ComponentEditor();
it doesn't work. I have this error : "field is undefined", though I defined it yet !

Does anyone can help me ?

Thanks,
Tom