forumuser1080
16 Mar 2011, 5:24 PM
I cannot seem to get the scope that I want in my handler for a button.
Here I am extending FormPanel, I add some fields because I will want to create a couple different instances of this panel with the same fields
Ext.ns('MyApp');
MyApp.FormPanel = Ext.extend(Ext.form.FormPanel, {
initComponent: function() {
Ext.apply(this, {
items: [{
xtype: 'textfield',
fieldLabel: 'first name'
},{
xtype: 'textfield',
fieldLabel: 'last name'
}]
});
MyApp.FormPanel.superclass.initComponent.apply(this, arguments);
}
});
and later in code I new up one of my form panels but I want to add a button, each panel I create will have different functionality for the buttons I need to add.
...
layout: 'border',
items : [new MyApp.FormPanel({
title: 'my form panel',
region: 'center',
buttons: [{
text: 'Save',
handler: function() {
var values = this.form.getFieldValues();
},
scope: this // I know this won't work, need the form panel I just created
}]
})]
})
...
I want the scope of the handler to be the FormPanel itself so that I can get some info from the form.
Is there any way to set the scope correctly when I insert the a new panel into items like I am doing?
Here I am extending FormPanel, I add some fields because I will want to create a couple different instances of this panel with the same fields
Ext.ns('MyApp');
MyApp.FormPanel = Ext.extend(Ext.form.FormPanel, {
initComponent: function() {
Ext.apply(this, {
items: [{
xtype: 'textfield',
fieldLabel: 'first name'
},{
xtype: 'textfield',
fieldLabel: 'last name'
}]
});
MyApp.FormPanel.superclass.initComponent.apply(this, arguments);
}
});
and later in code I new up one of my form panels but I want to add a button, each panel I create will have different functionality for the buttons I need to add.
...
layout: 'border',
items : [new MyApp.FormPanel({
title: 'my form panel',
region: 'center',
buttons: [{
text: 'Save',
handler: function() {
var values = this.form.getFieldValues();
},
scope: this // I know this won't work, need the form panel I just created
}]
})]
})
...
I want the scope of the handler to be the FormPanel itself so that I can get some info from the form.
Is there any way to set the scope correctly when I insert the a new panel into items like I am doing?