PDA

View Full Version : When to hide buttons in toolbar



Alexei Ptitchkin
23 May 2012, 2:41 PM
Hi I'm trying hide buttons on toolbar and getting error "Ext.getCmp("SelectBtn") is undefined".
I guess that during initComponent() buttons wasnt rendered yet.
on which event or method I can hide buttons?


initComponent: function() {


this.dockedItems = [{
xtype: 'toolbar',
dock:'top',
items: [
{
minWidth: 80,
text: 'Select',
id:'SelectBtn',
iconCls: 'icon-check',

},{
minWidth: 80,
text: 'Edit',
id: 'editBtn',
iconCls: 'icon-modify',
hidden: true,

},{
minWidth: 80,
text: 'New Item',
id: 'NewItemBtn',
iconCls: 'icon-modify',
},{
iconCls: 'icon-delete',
text: 'Delist',
id: 'DelistBtn',
action: 'delete'
minWidth: 80,
iconCls: 'icon-delete',

}
},{
minWidth: 80,
text: 'SKU Report by Product',
iconCls: 'icon-report',
handler : function() {
exportToExcel('P');
}
},{
minWidth: 80,
text: 'SKU Report by Account',
iconCls: 'icon-report',
handler : function() {
exportToExcel('D')
}
}]
}];
if (isUserInquiry){
Ext.getCmp('SelectBtn').hide();
Ext.getCmp('DelistBtn').hide();
Ext.getCmp('NewItemBtn').hide();
}
this.callParent(arguments);

}


Thanks.

vietits
23 May 2012, 4:18 PM
You should wait for 'render' event to do that. However, with your case, you can do the same thing by configuring 'hidden' of each button basing on isUserInquiry.


initComponent: function() {
this.dockedItems = [{
xtype: 'toolbar',
dock:'top',
items: [{
minWidth: 80,
text: 'Select',
id:'SelectBtn',
iconCls: 'icon-check',
hidden: isUserInquiry

Alexei Ptitchkin
24 May 2012, 4:13 AM
You should wait for 'render' event to do that. However, with your case, you can do the same thing by configuring 'hidden' of each button basing on isUserInquiry.


initComponent: function() {
this.dockedItems = [{
xtype: 'toolbar',
dock:'top',
items: [{
minWidth: 80,
text: 'Select',
id:'SelectBtn',
iconCls: 'icon-check',
hidden: isUserInquiry





Great answer! Thanks a lot!