Reputation: 37506
I cannot see to get the buttons from an Ext.FormPanel defined like this:
Ext.apply({
....
buttons: [
{
text: 'Save',
itemId: 'btnSave'
}
]
});
I've tried getComponent on the FormPanel instance, but that doesn't return btnSave. Is btnSave on a different element than the rest of the form?
Upvotes: 4
Views: 13069
Reputation: 1
In Extjs 4.2, I had similar code to yours with buttons at the bottom of a window.
This worked for me:
var bbar = this.getDockedItems('toolbar[dock="bottom"]')[0];
var button = bbar.getComponent('btnSave');
The toolbar and items are not in your code but they are implied with buttons:[{}]
Upvotes: 0
Reputation: 1310
You can't use getComponent()
because the buttons are not part of the items
config.
getComponent() - "Examines this container's items property and gets a direct child component of this container."
You could give the button an id
and then use Ext.getCmp()
or use component query as @limscoder shows.
Upvotes: 2
Reputation: 3167
You should be able to use the container's "query" method to retrieve descendant components:
panel.query("#btnSave")
Upvotes: 2