How do I get a link to a checkbox in a toolbar?

Can anyone tell me the preferred way to get a link to a checkbox if it's on the toolbar in the EditorGridPanel? I would just like to call getValue () on it so I can do something with it.

My EditorGridPanel is built the same as below (plus a few more config properties):

var grid = new Ext.grid.EditorGridPanel({    
tbar: new Ext.Toolbar({
            width: 200,
            height: 30,
            items: [
                {
                    xtype: 'checkbox',
                    name: 'field1',
                    boxLabel: 'Order aktiverad'
                }
            ]
        })
 });

      

Thank!

+2


source to share


4 answers


use the "ref" config like this:

var grid = new Ext.grid.EditorGridPanel({    
tbar: new Ext.Toolbar({
            width: 200,
            height: 30,
            items: [
                {
                    xtype: 'checkbox',
                    name: 'field1',
                    boxLabel: 'Order aktiverad',
                    ref: '../myCheckbox'
                }
            ]
        })
});

var checkboxValue = grid.myCheckbox.getValue();

      



See also the "ref" config parameter here: http://docs.sencha.com/ext-js/3-4/#!/api/Ext.Component

+1


source


Can't you check the itemId checkbox and use getCmp ()?



+4


source


Thanks for the answer. Pushed me in the right direction; I didn't even know about getCmp ().

Tried Ext.getCmp () with itemId but it didn't find it. I gave it an id and it worked:

tbar: [
                {
                    xtype: 'checkbox',
                    name: 'field1',
                    boxLabel: 'Order aktiverad',

                    id : 'cb_order_active'
                },
                {
                    //Button        
                    text: 'Test',
                    handler : function(){
                        alert(Ext.getCmp('cb_order_active').getValue());
                    }
                }
            ]

      

+1


source


itemId is supposed to be used with the container that renders the component you want to receive. Also, for itemId, you should use getComponent () function instead of getCmp ().

So, if you have a component with itemId "a" that is in container "c", you can access "a" using

c.getComponent ('a')

The following link explains the difference between id and itemId.

http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.form.Checkbox-cfg-itemId

+1


source







All Articles