如何获取复选框的值 [英] How to get the value of checkbox

查看:75
本文介绍了如何获取复选框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取复选框的值?

var tb = new Ext.Toolbar();

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

是否有可能在tb之外获取复选框的值.我已经做了类似的事情,但是没有触发

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

推荐答案

这对我有用:

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()}
                    }
                }

            });

然后:

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

这篇关于如何获取复选框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆