View Full Version : How to target docked button in panel?
rfender
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"
}]
}
skirtle
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() {
this.callParent();
// 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;
...
}
}
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.