1. #1
    Ext User
    Join Date
    Apr 2007
    Posts
    131
    Vote Rating
    0
    MoShAn480 is on a distinguished road

      0  

    Default 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.

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    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.

  3. #3
    Ext User
    Join Date
    Apr 2007
    Posts
    131
    Vote Rating
    0
    MoShAn480 is on a distinguished road

      0  

    Default 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!

  4. #4
    Ext User
    Join Date
    Apr 2007
    Posts
    37
    Vote Rating
    0
    froggman2k is on a distinguished road

      0  

    Default 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

  5. #5
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    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?

  6. #6
    Ext User
    Join Date
    Apr 2007
    Posts
    37
    Vote Rating
    0
    froggman2k is on a distinguished road

      0  

    Default


    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);

  7. #7
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    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.

    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)
    });
    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.

  8. #8
    Sencha User
    Join Date
    Jul 2009
    Posts
    66
    Vote Rating
    1
    ssawchenko is on a distinguished road

      0  

    Default


    Quote Originally Posted by tryanDLS View Post
    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.
    Looks like you can also do something like this as long as you give ids to your menu/menu items:

    var menuButton = myMenu.items.get("myId");

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi