Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
57
rated 0 times [  63] [ 6]  / answers: 1 / hits: 36542  / 15 Years ago, mon, december 21, 2009, 12:00:00

How to get the value of a check box?



var tb = new Ext.Toolbar();

tb.add({
xtype: 'checkbox',
boxLabel: 'Expand Groups by Default',
id: 'GetChkBoxValue',
checked: true,
handler: function() {
alert(this.getValue())
}
});


Is it possible to get the value of the checkbox outside tb.I have done something like this but it is not firing



Ext.getCmp('GetChkBoxValue').getValue(); 

More From » extjs

 Answers
11

Here is what worked for me:



var expandAllGroupsCheckbox = Ext.create(

{
xtype: 'checkbox',
boxLabel: 'Expand Groups by Default',
id: 'chkid',
checked: true,
afterRender: function() {
Ext.form.Checkbox.superclass.afterRender.call(this);
alert(this.getValue());// giving true
this.checkChanged();
},
checkChanged: function()
{
var checked = expandAllGroupsCheckbox.getValue();
gv.startCollapsed = !checked;
if ( gv.mainBody )
{
gv.toggleAllGroups( !checked );
}
},
listeners: {
check: {
fn: function(){expandAllGroupsCheckbox.checkChanged()}
}
}

});


And then:



tbar: [
expandAllGroupsCheckbox
,
{
xtype: 'tbbutton',
icon: '/images/icon_list_props.gif',
handler: function() {
ShowPreferencesPage();
}
}
],

[#98021] Thursday, December 17, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
amari

Total Points: 736
Total Questions: 111
Total Answers: 90

Location: Saint Pierre and Miquelon
Member since Fri, Jan 28, 2022
2 Years ago
;