-
11 Apr 2007 9:41 AM #1
Dynamically disabling a menu item
Dynamically disabling a menu item
Hi.
I am trying to dynamically disable a menu item on the toolbar. I am using the following code to create the toolbar and menu item:
var tb = new Ext.Toolbar('toolbar');
tb.add({
icon: 'images/save.gif', // icons can also be specified inline
text: 'Save',
id: 'save',
cls: 'x-btn-text-icon',
handler:disableChatLinks,
tooltip: '<b>Quick Tips</b><br/>Icon only button with tooltipps'
}, '-');
tb.add({
icon: 'images/print.gif', // icons can also be specified inline
text: 'Print',
id: 'print',
cls: 'x-btn-text-icon',
tooltip: '<b>Quick Tips</b><br/>Icon only button with tooltipps',
handler: addUserCannedMessage
}, '-');
Then i am trying to disable the print button iusing:
Ext.get('print').disable=true;
This does not do anything. Ext.get does seem to get a reference to the item though. Any thoughts? Thanks.
-
11 Apr 2007 9:58 AM #2
You need to disable the button, not the element. If you call addButton instead of add, you'll get back a ref to the button which you can save, to later call disable.
Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
11 Apr 2007 10:14 AM #3
Awesome, it worked!
Awesome, it worked!
Cool thanks. That worked out great. Still have alot to learn about this Toolkit, but i am loving learning it!
-
13 Apr 2007 1:08 PM #4
Button greyed out - Events still happen tho
Button greyed out - Events still happen tho
So I disabled my button, and the button does look greyed out... But, um, the onclick events still happen.
The button gets created and stored:
this.attachButton = this.toolbar.addButton({
text: _L('Attach')
, className: 'mx-toolbar-button'
, id: view.getId() + '-wdr-compose-attach-button'
, disabled: false
});
then later I say:
this.toolbar.attachButton.disable();
It does grey out the button, but all its events still work. The point of disabling the button is to stop the events until the user takes a certain action. Any help is appreciated.
Thanks!
Cynthia
-
13 Apr 2007 1:57 PM #5
Even with .33, I don't see how that could be happening.
Can you set a BP in ToolbarButton.onClick and check if it's really disabled?Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
13 Apr 2007 2:08 PM #6
It's still calling the onClick function, even with an override.
I don't know if it matters, but this how I'm adding the onclick event to the button (it happens later when my controller functions get initialized):
YAHOO.util.Event.on(id, 'click', this.handleAttach, this.panel, true);
-
13 Apr 2007 2:21 PM #7
Yeah, that will always get called b/c it's just another listener in the chain. In your button config, add a 'click' property which is the handler.
Look at the feedviewer example to see more of this. Note also, that in 1.0 'click' changes to 'handler' and you don't have to do the createDelegate - it's done for you.Code:this.toolbar.addButton({ text: _L('Attach') , className: 'mx-toolbar-button' , id: view.getId() + '-wdr-compose-attach-button' , disabled: false , click: this.handleAttach.createDelegate(this) });Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
16 Dec 2009 1:52 PM #8


Reply With Quote