View Full Version : How to target docked button in panel?

20 Sep 2012, 1:47 PM
If I have a panel with buttons defined in the buttons config, how can I target those buttons later?

id: 'somePanel',
xtype: 'panel',
buttons: [{
id: "myButton",
xtype: "button"

20 Sep 2012, 4:53 PM
I'd avoid assigning your components ids if I were you.

The easiest way is probably to use a Component Query. You can query for them in a number of ways depending on the circumstances but itemId is a common choice:

Ext.define('MyPanel', {
extend: 'Ext.panel.Panel',

buttons: [{
itemId: 'myButton',
xtype: 'button'

initComponent: function() {

// Store a reference to the button rather than repeating the query every time
this.saveButton = this.down('#myButton');


// Some arbitrary method that needs a reference to the button
myMethod: function() {
var saveButton = this.saveButton;