1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    45
    Answers
    2
    Vote Rating
    0
    cooperka is on a distinguished road

      0  

    Default Answered: Enable comboBox on button click?

    Answered: Enable comboBox on button click?


    I have a disabled comboBox in a form panel, and I would like to enable it when the user clicks a button. I have tried to follow the example here regarding Ext.get() but it doesn't work. My entire code is below--the important part is in the onButtonClick function.
    Code:
    Ext.define('MyApp.view.MyForm', {
        extend: 'Ext.form.Panel',
    
    
        height: 250,
        width: 400,
        bodyPadding: 10,
        title: 'My Form',
    
    
        initComponent: function() {
            var me = this;
    
    
            Ext.applyIf(me, {
                items: [
                    {
                        xtype: 'combobox',
                        anchor: '100%',
                        disabled: true,
                        id: 'box',
                        fieldLabel: 'Label'
                    },
                    {
                        xtype: 'button',
                        text: 'MyButton',
                        listeners: {
                            click: {
                                fn: me.onButtonClick,
                                scope: me
                            }
                        }
                    }
                ]
            });
    
    
            me.callParent(arguments);
        },
    
    
        onButtonClick: function(button, e, options) {
            console.log(Ext.get('box'));
            console.log(Ext.get('box').dom.disabled);
            Ext.get('box').dom.disabled = false; // Doesn't work
        }
    
    
    });

  2. So you need to get a reference to the combo and call enable on it. Currently, you are getting a reference to the combo's element and manipulating the dom. The simplest way to achieve what you want (which I don't recommend), is to use Ext.getCmp( 'box' ).enable() in your onButtonClick listener.

    The better way to do this is to do it in your controller. In the this.control call in your controller's init method you should put the click listener on your button. Don't use ids. If you have to, use itemIds instead. I would have a ref for your combo. It would also be good to have an alias on the view so your ref and control selector (component queries) are more specific.

  3. #2
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    536
    Answers
    61
    Vote Rating
    70
    Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough Tim Toady is a jewel in the rough

      1  

    Default


    So you need to get a reference to the combo and call enable on it. Currently, you are getting a reference to the combo's element and manipulating the dom. The simplest way to achieve what you want (which I don't recommend), is to use Ext.getCmp( 'box' ).enable() in your onButtonClick listener.

    The better way to do this is to do it in your controller. In the this.control call in your controller's init method you should put the click listener on your button. Don't use ids. If you have to, use itemIds instead. I would have a ref for your combo. It would also be good to have an alias on the view so your ref and control selector (component queries) are more specific.

  4. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    45
    Answers
    2
    Vote Rating
    0
    cooperka is on a distinguished road

      0  

    Default


    Very helpful thank you.

Thread Participants: 1

Tags for this Thread

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